一、先前准备@H_502_2@
1.在进行源码构建之前,你应该确认你已经完成了如下安装:@H_502_2@
Android SDK version 23(compileSdkVersion in Build.gradle)@H_502_2@
SDK build tools Version 23.0.1(buildToolsVersion in build.gradle)@H_502_2@
Android Support Repository>=17(for Android Support Library)@H_502_2@
Android NDK@H_502_2@
在Android SDK Manager中查看,并安装;@H_502_2@
@H_502_2@
@H_502_2@
在Android Developers(http://developer.android.com/intl/zh-cn/ndk/guides/setup.html)下载对应版本的NDK,并安装;@H_502_2@
2.声明你的Gradle和Andorid SDK的位置;@H_502_2@
声明ANDROID_SDK和ANDROID_NDK环境变量;@H_502_2@
sdk.dir=/Users/your_unix_name/android-sdk-macosx@H_502_2@
ndk.dir=/Users/your_unix_name/android-ndk/android-ndk-r10e@H_502_2@
git clone https://github.com/facebook/react-native.git@H_502_2@
./gradlew :Example:UIExplorer:android:app:installDebug@H_502_2@
提示2:@H_502_2@Installing APK 'app-debug.apk' on 'm1 Metal - 5.1' for app:debug@H_502_2@@H_502_2@
03:39:32 E/1194330994@H_502_2@: Error while uploading app-debug.apk : Unknown failure ([CDS]close[0])@H_502_2@@H_502_2@@H_502_2@
Unable to install /home/pengcx/ReactNativeWorkspace/react-native/Examples/UIExplorer/android/app/build/outputs/apk/app-debug.apk@H_502_2@@H_502_2@
> com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Unable to upload some APKs@H_502_2@@H_502_2@
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.@H_502_2@@H_502_2@
pengcx@pengcx-Ubuntu:~/ReactNativeWorkspace/react-native$ sudo ./gradlew :Example:UIExplorer:android:app:installDebug@H_502_2@@H_502_2@
Build file '/home/pengcx/ReactNativeWorkspace/react-native/ReactAndroid/build.gradle' line: 3、@H_502_2@@H_502_2@
> Gradle version 2.2 is required. Current version is 2.11. If using the gradle wrapper,try editing the distributionUrl in /home/pengcx/ReactNativeWorkspace/react-native/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip@H_502_2@@H_502_2@
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.@H_502_2@@H_502_2@
distributionUrl=https://services.gradle.org/distributions/gradle-2.2-all.zip@H_502_2@@H_502_2@@H_502_2@
3.启动服务器@H_502_2@
ERROR EACCES: permission denied,scandir '/home/pengcx/ReactNativeWorkspace/react-native/ReactAndroid/build/third-party-ndk/boost/boost_1_57_0'@H_502_2@@H_502_2@
{"errno":-13,"code":"EACCES","syscall":"scandir","path":"/home/pengcx/ReactNativeWorkspace/react-native/ReactAndroid/build/third-party-ndk/boost/boost_1_57_0"}@H_502_2@@H_502_2@
The triggering condition was at timestamp=1462014845@H_502_2@: inotify-add-watch(/home/pengcx/ReactNativeWorkspace/react-native/ReactAndroid/build/tmp/expandedArchives/boost_1_57_0.zip_an0bykhqkyzSEOwihr2ej31lv/boost_1_57_0/boost/geometry/strategies/concepts) -> The user limit on the total number of inotify watches was reached; increase the fs.inotify.max_user_watches sysctl\@H_502_2@@H_502_2@@H_502_2@
{"watchmanResponse":{"version":"4.5.0","error":"A non-recoverable condition has triggered. Watchman needs your help!\nThe triggering condition was at timestamp=1462014845@H_502_2@: inotify-add-watch(/home/pengcx/ReactNativeWorkspace/react-native/ReactAndroid/build/tmp/expandedArchives/boost_1_57_0.zip_an0bykhqkyzSEOwihr2ej31lv/boost_1_57_0/boost/geometry/strategies/concepts) -> The user limit on the total number of inotify watches was reached; increase the fs.inotify.max_user_watches sysctl\nAll requests will continue to fail with this message until you resolve\nthe underlying problem. You will find more information on fixing this at\nhttps://facebook.github.io/watchman/docs/troubleshooting.html#poison-inotify-add-watch\n"}}@H_502_2@@H_502_2@@H_502_2@
1462014845@H_502_2@: inotify-add-watch(/home/pengcx/ReactNativeWorkspace/react-native/ReactAndroid/build/tmp/expandedArchives/boost_1_57_0.zip_an0bykhqkyzSEOwihr2ej31lv/boost_1_57_0/boost/geometry/strategies/concepts) -> The user limit on the total number of inotify watches was reached; increase the fs.inotify.max_user_watches sysctl@H_502_2@@H_502_2@@H_502_2@
https://facebook.github.io/watchman/docs/troubleshooting.html#poison-inotify-add-watch@H_502_2@@H_502_2@
at BunserBuf.<anonymous> (/home/pengcx/ReactNativeWorkspace/react-native/node_modules/sane/node_modules/fb-watchman/index.js:95:23)@H_502_2@@H_502_2@
at BunserBuf.process (/home/pengcx/ReactNativeWorkspace/react-native/node_modules/bser/index.js:289:10)@H_502_2@@H_502_2@
at /home/pengcx/ReactNativeWorkspace/react-native/node_modules/bser/index.js:244:12@H_502_2@@H_502_2@
Seehttp://facebook.github.io/react-native/docs/troubleshooting.html@H_502_2@@H_502_2@@H_502_2@
4.手机端Reload JS,运行如下:@H_502_2@
@H_502_2@
@H_502_2@