linux平臺(tái)安裝React Native遇到的坑

3年前我在windows平臺(tái)安裝過React Native,我一直都記憶猶新,那個(gè)時(shí)候facebook剛推出支持安卓,然后花了一天的時(shí)間在自己的window電腦上配置好了,還是很興奮的,安裝博客地址如下

Android之Windows下搭建React Native Android開發(fā)環(huán)境(差不多搞了一天)

現(xiàn)在我的開發(fā)環(huán)境是ubuntu,所以需要在這個(gè)平臺(tái)安裝react native,遇到的坑如下
 
問題   1

ERROR  Metro Bundler can't listen on port 8081

解決辦法

因?yàn)橛械胤秸加昧?081端口,所以找到這個(gè)端口的進(jìn)程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.

解決辦法

這個(gè)在我們r(jià)eact native init program里面我們項(xiàng)目里面的android文件夾里面少了local.properties文件,在之前的項(xiàng)目目錄下,把這個(gè)文件拷貝到這個(gè)目錄就行了


最后編譯好的部分顯示如下

../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
深信服三年半工作經(jīng)驗(yàn),目前就職游戲廠商,希望能和大家交流和學(xué)習(xí),
微信公眾號(hào):編程入門到禿頭 或掃描下面二維碼
零基礎(chǔ)入門進(jìn)階人工智能(鏈接)