linux平台安装React Native遇到的坑

3年前我在windows平台安装过React Native,我一直都记忆犹新,那个时候facebook刚推出支持安卓,然后花了一天的时间在自己的window电脑上配置好了,还是很兴奋的,安装博客地址如下

Android之Windows下搭建React Native Android开发环境(差不多搞了一天)

现在我的开发环境是ubuntu,所以需要在这个平台安装react native,遇到的坑如下

 

问题   1

ERROR  Metro Bundler can't listen on port 8081

解决办法

因为有地方占用了8081端口,所以找到这个端口的进程pid,然后kill就行

sudo lsof -i :8081
kill pid

 

 

 

问题 2

A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

解决办法

这个在我们react native init program里面我们项目里面的android文件夹里面少了local.properties文件,在之前的项目目录下,把这个文件拷贝到这个目录就行了

 

最后编译好的部分显示如下

../react-native run-android
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareAndroidArchLifecycleRuntime100Library
:app:prepareComAndroidSupportAnimatedVectorDrawable2610Library
:app:prepareComAndroidSupportAppcompatV72610Library
:app:prepareComAndroidSupportSupportCompat2610Library
:app:prepareComAndroidSupportSupportCoreUi2610Library
:app:prepareComAndroidSupportSupportCoreUtils2610Library
:app:prepareComAndroidSupportSupportFragment2610Library
:app:prepareComAndroidSupportSupportMediaCompat2610Library
:app:prepareComAndroidSupportSupportV42610Library
:app:prepareComAndroidSupportSupportVectorDrawable2610Library
:app:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library
:app:prepareComFacebookFrescoDrawee190Library
:app:prepareComFacebookFrescoFbcore190Library
:app:prepareComFacebookFrescoFresco190Library
:app:prepareComFacebookFrescoImagepipeline190Library
:app:prepareComFacebookFrescoImagepipelineBase190Library
:app:prepareComFacebookFrescoImagepipelineOkhttp3190Library
:app:prepareComFacebookReactReactNative0561Library
:app:prepareComFacebookSoloaderSoloader030Library
:app:prepareOrgWebkitAndroidJscR174650Library
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:bundleDebugJsAndAssets SKIPPED
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:javaPreCompileDebug
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithDexForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:app:transformNativeLibsWithStripDebugSymbolForDebug UP-TO-DATE
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateSigningDebug
:app:packageDebug UP-TO-DATE
:app:assembleDebug UP-TO-DATE
:app:installDebug
Installing APK 'app-debug.apk' on 'HUAWEI RIO-UL00 - 6.0.1' for app:debug
Installed on 1 device.

BUILD SUCCESSFUL

 

相关文章

这篇文章主要讲解了“FlutterComponent动画的显和隐怎么实现...
这篇文章主要讲解了“flutter微信聊天输入框功能如何实现”,...
本篇内容介绍了“Flutter之Navigator的高级用法有哪些”的有...
这篇文章主要介绍“Flutter怎么使用Android原生播放器”,在...
Flutter开发的android端如何修改APP名称,logo,版本号,具体...
Flutter路由管理初识路由概念一.路由管理1.1.Route1.2.Mater...