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
作者:chen.yu
深信服三年半工作经验,目前就职游戏厂商,希望能和大家交流和学习,
微信公众号:编程入门到秃头 或扫描下面二维码
零基础入门进阶人工智能(链接)