ReactNative学习中遇到的坑

          这篇文章将记录以后学习ReactNative中遇到的坑。现在网上能查到的一些基本的坑就不写了。

(1)第一个:今天移植安卓原生应用到ReactNative中,移植完后,出现无法连接的红色画面。正常情况下,我们是摇晃一下手机,出现一个选择的界面 点击DevSetting进入到设置界面去设置我们的IP和端口,但是今天我遇到一个问题,点击DevSetting的时候应用崩溃了。网上没查到解决办法,幸好突然看到我的AndoridStudio里面的报错日志。原来是有个activity没有注册。

<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>

去Manifest文件中注册完就不崩溃了。


(2)

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: Unable to upload some APKs

* 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.35 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

将  android/build.gradle  第 8 行的版本号改成  1.2.3  即可 

问题解决的地址


(3)运行别人的项目 出现Command `run-android` unrecognized. Did you mean to run this inside a react-native project?

    先npm inatall 之后在运行  。

    感觉 好麻烦~~ 不知道有没有好的方法


(4)   Application XXX has not been registered.This is either due to a require() error during initialization or failure to call AppRegistry.registerComponent. 

    这个问题是我先运行了一个别人的项目,之后运行我的项目的时候出现的。

解决方法 :先把上个项目的服务关了 在重新运行自己的项目


(5)

Caused by: java.lang.IllegalAccessError: tried to access method android.support.v4.net.ConnectivityManagerCompat.:(Lcom/facebook/react/bridge/ReactApplicationContext;)V from class com.facebook.react.modules.netinfo.NetInfoModule
 

这个错误是包冲突引起的 ,我新建的项目gradle中v7包是25.00  改成23.00就好了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值