前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >React Native android 常见错误和解决方法

React Native android 常见错误和解决方法

作者头像
chuchur
发布2022-10-25 14:31:25
2.7K0
发布2022-10-25 14:31:25
举报
文章被收录于专栏:禅境花园禅境花园

Unknown argument type 'attribute' in method -[RCTAppState getCurrentAppState:error:]. Extend RCTConvert to support this type.

这个 BUGXcode.11 引起的, 可以查看这个问题的提交记录,链接为:https://github.com/facebook/react-native/issues/25138 我们只需要找到 RCTModuleMethod.mm 这个文件 修改

这个函数插入 RCTReadString(input, "attribute((unused))") || 这行代码重新运行就行了。 这样项目就能启动了,而且打包的 app 也不会闪退了。

Could not determine java version from '11.0.1'.

更新 gradle 即可, 可参考 gradle 版本更新, 或者 JDK降级到 8 , 请参考Mac 安装和卸载 Java JDK

这个函数插入 RCTReadString(input, "**attribute**((**unused**))") || 这行代码重新运行就行了。 这样项目就能启动了,而且打包的 app 也不会闪退了。

Cannot add task 'wrapper' as a task with that name already exists.

Failed to install the following Android SDK packages as some licences have not been accepted.

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

  • create (or edit) ~/.bashrc
  • export ANDROID_HOME=/Users/你的用户名/Library/Android/sdk
  • export PATH={PATH}:{ANDROID_HOME}/tools
  • chmod 755 android/gradlew

org.gradle.api.resources. ResourceException: Could not get resource

Mac 中,点击 Android Studio > Preferences ),打开 Preferences 窗口。 Build,Execution,Deployment => Gradle => Android Studio , 勾选 Enable embedded Maven repository

Could not resolve all files for configuration ':app:releaseCompileClasspath

  1. 修改 android/build.gradlegoogle()方法的位置,见下方代码注释;
  1. 如果还不行,就升级 gradle 版本到 4.10.1

Failed to capture snapshot of input files for task ':app:javaPreCompileDebug

appbuild

Execution failed for task ':react-native-yunpeng-alipay:compileDebugJavaWithJavac'.

打开 ReactNative 根目录下的 node_modules 文件夹 找到 react-native-yunpeng-alipay 文件夹并打开 依次打开目录: android -> src -> main -> java -> com -> yunpeng -> alipay -> AlipayPackage.java

注释调这一行;

Execution failed for task 'xxx:verifyReleaseResources'

0.57 版本打包错误,SDK 版本不匹配问题

  • 首先在 node_modules 中找到报错的包里面的 build.gradle,比如我这个就是\node_modules\react-native-version-number\android\build.gradle
  • 修改这个build.gradle,使其与 android/build.gradle(也可能是 android/app/build.gradle)里面的 SDK 版本保持一致;
  • build.gradle 里的 compile 改为 implementation,因为 compile 已过时。

Execution failed for task ':app:processDebugManifest'

已经提示了合并错误 Manifest merger failed with multiple errors, see logs 打开 AndroidMainifest.xml => 点底部的 Merged Mainfest => 看到右边的合并错误, 点进去, 注释掉重复的就可以了 http://yifeng.studio/2017/07/09/android-manifest-merge-conflict/

Execution failed for task ':appbase:installDebugAndroidTest'.

快速定义错误, 进入终端输入 ./gradlew compileDebugJavaWithJavac --stacktrace 看看哪里报错了, 修正即可

Could not resolve com.squareup.okhttp3:okhttp:3.9.1.

Minimum supported Gradle version is 4.6. Current version is 4.1.

这个问题是 GradleGradle 插件版本对应不上造成的 gradle 插件版本配置位置:project 对应的 build.gradle 文件中

gradle 版本配置位置: gradle/wrapper/gradle-wrapper.properties 文件中

版本对应关系如下

很明显对应不上,gradle 4.1 应该对应 3.0.0classpath 对应的 3.3.0 改为 3.0.0 即可

Failed to find Build Tools revision 26.0.2

底下报错会提示你安装构建工具, 你安装即可. 不要手贱点 update.

本文将持续更新...
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-04-07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Unknown argument type 'attribute' in method -[RCTAppState getCurrentAppState:error:]. Extend RCTConvert to support this type.
    • Could not determine java version from '11.0.1'.
      • Cannot add task 'wrapper' as a task with that name already exists.
        • Failed to install the following Android SDK packages as some licences have not been accepted.
          • Could not install the app on the device, read the error above for details.
            • org.gradle.api.resources. ResourceException: Could not get resource
              • Could not resolve all files for configuration ':app:releaseCompileClasspath
                • Failed to capture snapshot of input files for task ':app:javaPreCompileDebug
                  • Execution failed for task ':react-native-yunpeng-alipay:compileDebugJavaWithJavac'.
                    • Execution failed for task 'xxx:verifyReleaseResources'
                      • Execution failed for task ':app:processDebugManifest'
                        • Execution failed for task ':appbase:installDebugAndroidTest'.
                          • Could not resolve com.squareup.okhttp3:okhttp:3.9.1.
                            • Minimum supported Gradle version is 4.6. Current version is 4.1.
                            • Failed to find Build Tools revision 26.0.2
                            领券
                            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档