初始化RN项目后,经测试在模拟器上能正常跑起来,我的手机不行,经一番搜索现将解决方案备份
手机出错信息如下
<pre>
03:02:52 E/515609544: Error while uploading app-debug.apk : Unknown failure ([CDS]close[0])
Unable to install /home/meijun/RN20170724/AwesomeProject/android/app/build/outputs/apk/app-debug.apk
com.android.ddmlib.InstallException: Failed to install all
at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:89)
at com.android.ddmlib.Device.installPackages(Device.java:904)
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:137)
at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228)
</pre>
进入项目根目录 将项目\android\build.gradle 文件中的com.android.tools.build:gradle:2.2.3,改成1.2.3
运行
控制台再次报下面错误
<pre>
Build file '/home/meijun/RN20170724/AwesomeProject/android/app/build.gradle' line: 1
- What went wrong:
A problem occurred evaluating project ':app'.
Failed to apply plugin [id 'com.android.application']
Gradle version 2.2 is required. Current version is 2.14.1. If using the gradle wrapper, try editing the distributionUrl in /home/meijun/RN20170724/AwesomeProject/android/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
</pre>
根据提示
进入AwesomeProject\android\gradle\wrapper\gradle-wrapper.properties,这个文件, 改为如下
<pre>
distributionUrl=https://services.gradle.org/distributions/gradle-2.2-all.zip
</pre>
再次运行,即可
2,手机无法显示RN Dev setting 选项
请检查是否开启了悬浮窗权限,(rn官网只填了小米,其实我的魅族也限制了弹窗啊啊啊啊啊啊,花了我好久找这个问题)