react-native 遇到的坑汇总(补充中)

来源:互联网 发布:网络电视机软件下载 编辑:程序博客网 时间:2024/06/05 02:48

1.

Could not create ADB Bridge. ADB location: **\platform-tools\adb.exe

app:installDebug

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:installDebug’.

    com.android.builder.testing.api.DeviceException: Could not create ADB Bridge. ADB location: D:\androidstudiosdk\platform-tools\adb.exe

  • 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: 9 mins 7.292 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

解决办法:
adb devices 查看adb 是否正常
adb

查看环境变量是否正确:D:\androidstudiosdk\platform-tools

2.

com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE

installDebug FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:installDebug’.

    com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.blemanager signatures do not match the previously installed version; ignoring!

  • 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: 30.235 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

3.

ADB server didn’t ACK * failed to start daemon *

ADB server didn’t ACK
* failed to start daemon *
error:
Starting the app (D:\androidstudiosdk/platform-tools/adb shell am start -n com.blemanager/.MainActivity…
adb server version (31) doesn’t match this client (39); killing…
error: protocol fault (couldn’t read status): No error
* daemon started successfully *
Starting: Intent { cmp=com.blemanager/.MainActivity }

签名不同导致的安装失败,可以卸载原app后重新安装

4.

could not connect to development server

connect

手机menu–dev settings–设置ip和端口号,ip同电脑。

5.

adb server is out of date. killing…

ADB server didn’t ACK
* failed to start daemon *
error:

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

Sdk更新后出现了这个问题。排除端口号占用问题。最后确定是adb版本号不匹配造成的:sdk/platform-tools 下执行adb version 版本号是 1.0.39 而模拟器下的adb版本号是1.0.31 (夜神、genymotion均是),而在AndroidStudio下模拟器正常工作。

解决办法:尝试将模拟器下adb 替换为sdk下的adb,重启计算机后,仍报错。最后尝试将platform-tools下adb替换为原来的1.0.31版本,再次运行模拟器成功。

6.

adb server version (31) doesn’t match this client (39); killing…

error: could not install smartsocket listener: cannot bind to 127.0.0.1:5037: 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 (10048)

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application’s support team for more information.
could not read ok from ADB Server
* failed to start daemon *
error: cannot connect to daemon

Adb 版本号与模拟器版本号不匹配导致,将adb版本号降级后解决。
解决办法:
D:\androidstudiosdk\platform-tools 下替换adb.exe
使二者版本号一致。

7.

Packager can’t listen on port 8081

端口号8081被占用。
解决办法:
方案一:
修改react-native 端口号
React-native start —port=8088
React-native run-android
方案二:
找到使用该端口号的进程,杀死。
Netstat -ano
Tasklist|findstr “8081”
Kill -9

8.

Application * has not been registered.

registered

注册的应用名称和实际的不一致。

确保index.js 中AppRegistry.registerComponent(‘comDemos’, () => App); 组件名一致。

9.

unable to load script from assets ‘index.android bundle’ ,make sure your bundle is packaged correctly or youu’re runing a packager server

load

在android/app/src/main 下新建文件夹assets,执行如下命令,生成index.andorid.js和index.android.bundle。需收手敲下条命令。
react-native bundle –platform android –dev false –entry-file index.android.js –bundle-output android/app/src/main/assets/index.android.bundle –assets-dest android/app/src/main/res/

10.

undefined is not an object

检查提示文件/相关文件是否有语法错误。

11.

Could not run adb reverse: Command failed:

D:\androidstudiosdk/platform-tools/adb -s 192.168.103.101:5555 reverse tcp:8081 tcp:8081
Adb reverse 支持5.0以上版本

Adb devices

Adb reverse tcp:8081 tcp:8081

12.

Cannot find entry file index.android.js in any of the roots

Index.android.js存在,却频频提示找不到。
404

解决办法:
使用以前的nodemodules替换当前的nodemodules,在浏览器中输入http://localhost:8081/index.android.bundle?platform=android

如果显示以下数据,则表示正常。

localhost

原创粉丝点击