React-native错误,更新中......

1、使用

abd reverse tcp:8081 tcp:8081
react-native run-android

最后一行报错。

error: unknown host service

找到5037端口,关掉对应的pid即可。

netstat  -aon|findstr  "5037"

在资源管理器中,切换到进程,单击菜单栏查看 -> 选择列 -> 勾选PID,找到对应的pid,结束进程。

2、此方法无法解决见7

adb server version (31) doesn’t match this client (36); killing… 
* daemon started successfully * 
error: no devices/emulators found 

原来是genymotion中的adb命令被占用冲突了,直接打开genymotion的Setting,切换到第四个标签页(ADB),选择Use custom Android Sdk tools,然后选择我们开发使用的Sdk路径即可。

3、

java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

jdk版本不对,所需jre为1.8。而我的环境变量中还是1.7。解决方法:去官网下载jdk1.8,安装。然后将bin目录添加到环境变量。
这里写图片描述

4、

Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.pro4 signatures do not match the previously installed version; ignoring!

在真机上卸载掉相同名字的app。然后重新运行。

5、Execution failed for task ‘:app:processDebugResources’.

第一种方法:

Execution failed for task ':app:processDebugResources'.
> java.io.IOException: Could not delete path 'F:\android\project\reactnative\mypractice\android\app\build\generated\sour
ce\r\debug\android\support'.

解决方法(现在在项目目录下):

Run this command to clean project:

cd android && gradlew clean

After, run the following command to run project again:

cd .. && react-native run-android

来源:http://stackoverflow.com/questions/35158205/react-native-run-android-fail-on-appprocessdebugresources

第二种方法:
我后来自己发现的。删掉项目目录\android\app\build\下的所有文件夹,然后重新react-native run-android

5、AAPT err(Facade for): libpng error: Not a PNG file
参见:http://blog.youkuaiyun.com/tangxl2008008/article/details/51681933
关于mergeDebugResources类或者图片问题的错误,首先考虑这个方法。

方案一、在app文件夹下的build.gradle中配置下面两个信息,再clear project。

aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false

方案二、在android studio(drawable)中,依次点开后缀为png的图片,可以查看到图片的文件信息,如下图,将不为png的图片另存为png图片或者修改图片后缀为对应的图片格式。

6、F:\android\project\reactnative\mypractice\android\app\src\main\res\drawable-xxhdpi\1.jpg: Error: The resource name must start with a letter

Execution failed for task ':app:mergeDebugResources'.
> F:\android\project\reactnative\mypractice\android\app\src\main\res\drawable-xxhdpi\1.jpg: Error: The resource name mus
t start with a letter

因为drawable(drawable-xxhdpi)文件夹中图片的名字是以数字开头的,需要以字母开头。重命名就可以了。

7、adb server version (39) doesn’t match this client (36); killing…(解决!)

adb server version (39) doesn't match this client (36); killing...
error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037: 通常每个套接字地址(协议/网络地址/端口)只
允许使用一次。 (10048)
could not read ok from ADB Server
* failed to start daemon *
error: cannot connect to daemon

这次我真的懂了。

2无法解决这个问题。这次我将问题集中到错误本身。adb server version (39) doesn't match this client (36); killing...这里说的是adb server版本和adb client版本不一致。经过我的测试:

adb client version应该指的是 C:\windows\adb.exe的版本

adb server version应该指的是genymotion中setting->adb中所使用sdk中adb.exe的版本。如果使用的是Use genymotion Android Toos(default)那么adb使用的就是genymotion的安装目录比如我的D:\appData\Genymotion\tools下的adb.exe文件。如果使用的是Use custom Android SDK tools那么你肯定将这个目录指向自己的android sdk安装目录了比如我的F:\android\sdk,然后进入platform-tools文件夹,这里面的adb.exe就是adb server version了

当这两个adb版本不一致的时候会出现这个错误。如何查看版本:
命令行进入adb所在的文件夹,然后运行adb version命令就可查看版本。

解决方法:只要复制其中一个adb覆盖另一个文件夹下的adb即可解决这个问题。

8、

Element type is invalid. expected a string(for built-in components) or a class/function(for composite components) but got:object.

Check the render method of `setup`

说到底还是组件的问题,以前看别人答案说可能是组件名小写了。今天我犯得错误是导入Navigator错误。没加{}。这花费了我一个小时。
这样是错误的:

import Navigator from 'react-native-deprecated-custom-components';

应该是这样:

import { Navigator }from 'react-native-deprecated-custom-components';

9、路由页面切换动画问题

undefined is not an object(evaluating 'nextSceneConfig.defaultTransitionVelocity')

在使用Navigator的时候configureScene我使用的是

configureScene={() => {
    return Navigator.SceneConfigs.PushFormRight;
}}

上到上述错误SceneConfig,Transition故想到可能是动画问题(我使用{…this.props}传递navigator)。去掉了这个配置就可以了。

原因:多谢评论区@R3lish的提示,是单词拼写错误Navigator.SceneConfigs.PushFromRight

欢迎与我交流。

QQ: 1227620310
微信: a127620310
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值