ReactNative错误记录

https://www.jianshu.com/p/28a9d7485954

1.Could not install the app on the device, read the error above for details.

先检查是否已设置SDK环境变量ANDROID_HOME;
  然后linux下面可以在项目目录运行chmod 755 android/gradlew;
  windows的可以react-native init AwesomeProject初始化新项目,并把/android/gradlew.bat脚本文件copy到自己的项目;
  再react-native run-android



2.Failed to apply plugin [id 'com.android.library']

根据提示把

distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

改为

distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

并且在/android/build.gradle中根据Android Studio 的版本做一些修改(比如Android Studio 2.2)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

注:Android Studio 使用Gradle 这一高级构建工具包来自动化执行和管理构建流程


3.Execution failed for task':app:transformClassesWithDexForDebug'

当app中包含的method数量超过65k,就要开启multiDexEnabled
  在/android/app/build.gradle添加

    defaultConfig {
        multiDexEnabled true
    }
    dependencies {
        compile 'com.android.support:multidex:1.0.0'
    }

详见这里


4.Execution failed for task ':app:processDebugResources'

这个原因多种多样,这里只写我的方法
  把/android和/android/app下的build文件夹删除重新运行react-native run-android
  然后发现程序在building中卡在93%:app:transformclasseswithdexfordebug,原因是要启用transformclasseswithdexfordebug,buildToolsVersion最低要求
是"23.0.2",于是可以在/android/app/build.gradle中把buildToolsVersion改为"23.0.2"或以上


5.could not get batchedbridge make sure your bundle is packaged correctly OR unable to load script from assets index.android.bundle on windows

可能是开发服务器没有开启,React Native依赖于开发服务器与在模拟器中运行的应用程序进行通信。
  在项目根目录下npm run start或react-native start



6.Could not connect to development server

和上一个错误常一起出现,需要把开发服务器的index.android.bundle下载到app里面

    mkdir android/app/src/main/assets

    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
    //另一种方法
    //curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"


    react-native run-android


7.build文件冗余

把/android和/android/app下的build文件夹删除重新运行react-native run-android


8.listener is not supported for native driven evens

按照提示的路径文件进行一些修改

react-native-master\node_modules\react-native\Libraries\Animated\src\AnimatedImplementation.js
 this._listener = config.listener;
 this.__isNative = shouldUseNativeDriver(config);
 
//删除
- if (this.__isNative) {
- invariant(!this._listener, 'Listener is not supported for native driven events.');
- }
-

 if (__DEV__) {
 this._validateMapping();
 }


 __getHandler() {

//添加
+ if (this.__isNative) {
+ return this._listener;
+ }
+

 return (...args) => {
 const traverse = (recMapping, recEvt, key) => {
 if (typeof recEvt === 'number' && recMapping instanceof AnimatedValue) {


9.no dimemsion set for key window

  关闭react package manager窗口,删除build文件,重新react-native run-android



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值