2015-11-08 109 views
7

我想在Ubuntu 14.04上運行UIExplorer項目。 我已經安裝了SDK和NDK。 我能夠運行通常的反應原生項目(我創建的項目),但不是Examples from Official Repo無法運行「任何」反應原生示例項目

export ANDROID_NDK=/home/bozzmob/android-ndk-r10e/ 

我收到以下錯誤 -

執行失敗的任務 ':ReactAndroid:buildReactNdkLib'。

進程 '命令 '/家/ bozzmob /機器人-NDK-r10e/NDK建造'' 具有非零退出值完成2

日誌看喜歡 -

[email protected]:~/ReactJS/native/react-native# ./gradlew :Examples:UIExplorer:android:app:installDebug 
. 
. 
. 
:ReactAndroid:buildReactNdkLib 
make: Entering directory `/home/bozzmob/ReactJS/native/react-native/ReactAndroid/src/main/jni/react/jni' 
[armeabi-v7a] Compile++ thumb: reactnativejni <= OnLoad.cpp 
[armeabi-v7a] SharedLibrary : libfb.so 
[armeabi-v7a] SharedLibrary : libglog.so 
[armeabi-v7a] StaticLibrary : libdouble-conversion.a 
BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-> androideabi/4.8/liblto_plugin.so: file too short 

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short 

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short 

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short 

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short 

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short 

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short 

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short 

[armeabi-v7a] Prebuilt : libjsc.so <= /home/bozzmob/ReactJS/native/react-native/ReactAndroid/build/third-party-ndk/jsc/jni/armeabi-v7a/ 
[armeabi-v7a] Compile++ thumb: reactnative <= Bridge.cpp 
[armeabi-v7a] Compile++ thumb: reactnative <= Value.cpp 
[armeabi-v7a] Compile++ thumb: reactnative <= JSCHelpers.cpp 
[armeabi-v7a] Compile++ thumb: reactnative <= JSCExecutor.cpp 
[armeabi-v7a] Install : libjsc.so => /home/bozzmob/ReactJS/native/react-native/ReactAndroid/build/react-ndk/all/armeabi-v7a/libjsc.so 
[armeabi-v7a] Install : libgnustl_shared.so => /home/bozzmob/ReactJS/native/react-native/ReactAndroid/build/react-ndk/all/armeabi-v7a/libgnustl_shared.so 
make: *** [/home/bozzmob/ReactJS/native/react-native/ReactAndroid/build/react-ndk/all/armeabi-v7a/libgnustl_shared.so] Error 1 
make: *** Deleting file /home/bozzmob/ReactJS/native/react-native/ReactAndroid/build/react-ndk/all/armeabi-v7a/libgnustl_shared.so' make: *** Waiting for unfinished jobs.... make: Leaving directory/home/bozzmob/ReactJS/native/react-native/ReactAndroid/src/main/jni/react/jni' 
:ReactAndroid:buildReactNdkLib FAILED 

FAILURE: Build failed with an exception. 

    What went wrong: 
    Execution failed for task ':ReactAndroid:buildReactNdkLib'. 

     Process 'command '/home/bozzmob/android-ndk-r10e/ndk-build'' finished with non-zero exit value 2 

    Try: 
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

Total time: 1 mins 34.069 secs 

請讓我知道我在做什麼錯了?

回答

1

好像你在編譯react-native android的本地(C++)源時遇到問題。爲了開始新的項目,您不應該被要求這樣做(不需要NDK設置),因此您可以嘗試使用react-native init(請參閱this獲取說明)創建示例項目。之後,您可以將示例應用JS文件複製到新創建的項目中。

如果你仍然想從源代碼構建框架代碼,我需要一些更多的細節來幫助你。我建議爲ndk-build啓用詳細模式,然後你可以回到這裏輸出。爲了使冗長模式你需要修改這個文件:ReactAndroid/build.gradle,並添加'V=1'成參數,讓我聯繫到的代碼片段看起來是這樣的:

commandLine getNdkBuildFullPath(), 
     'NDK_PROJECT_PATH=null', 
     'V=1', 
     "NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk", 
     'NDK_OUT=' + temporaryDir, 
+0

非常感謝您的回覆。我做了你說的即'V = 1',這裏是我的輸出日誌 - https://gist.github.com/bozzmob/3cec8388bc7d75895160或http://pastebin.com/VesSeBts – bozzmob

+0

我也嘗試創建一個新的項目和複製文件並嘗試運行。它不幸的工作不好。它不運行並拋出相同的錯誤。但是,如果項目被創建並且我在那裏編寫我的代碼,它就可以正常工作。 – bozzmob

+1

所以看起來像ndk-build正在做werid,而不是將'libgnustl_shared.so'正確地複製到'react-native/ReactAndroid/build/tmp/buildReactNdkLib/local/armeabi-v7a/libgnustl_shared.so'你可以嘗試手動?你應該在你的android ndk分發文件夾下找到'./sources/cxx-stl/gnu-libstdC++/4.8/libs/armeabi-v7a/thumb/libgnustl_shared.so' – kzzzf

0

我也遇到同樣的生成錯誤並從找到的解決方案這post。您必須使用Android NDK r10e而不是最新的(r11)。