【问题标题】:React Native Android build failing with 'compileDebugJavaWithJavac' on several packagesReact Native Android 构建在多个包上因 \'compileDebugJavaWithJavac\' 而失败
【发布时间】:2022-12-11 07:57:03
【问题描述】:

我在同一个 React Native 项目中工作了几个月,最近 Android 构建开始失败。据我所知,我没有更改我的开发环境的任何内容,也没有更新或更改项目使用的任何包或依赖项。

Task :@react-native-community_async-storage:compileDebugJavaWithJavac FAILED

Task :@react-native-community_datetimepicker:compileDebugJavaWithJavac FAILED

Task :@react-native-community_toolbar-android:compileDebugJavaWithJavac FAILED

Task :@sentry_react-native:compileDebugJavaWithJavac FAILED

Task :@react-native-community_netinfo:compileDebugJavaWithJavac FAILED

我已经完成了从具有类似问题的其他问题中发现的所有以下内容

  • 在 android studio 中将项目与 gradle 文件同步
  • 在 android 目录下运行 gradlew clean 确实成功了,但是构建仍然失败
  • 检查gradle.properties文件中的android.useAndroidXandroid.enableJetifier都是真的
  • 检查我的 build.gradle 文件中是否有 implementation "com.facebook.react:react-native:+"。我尝试将它从 + 更改为我正在使用的 React Native 的实际版本,但没有任何区别。

我无论如何都不是专业的移动开发人员,所以我希望我遗漏了一些明显的东西,但我们将不胜感激任何帮助或建议。

【问题讨论】:

    标签: android react-native android-studio gradlew react-native-component


    【解决方案1】:

    几个星期以来,我一直在为同一个问题而苦苦挣扎。 Android 构建在 11 月刚刚停止工作。刚在这里找到解决方案(呸!)https://github.com/facebook/react-native/issues/35210

    2022 年 11 月 4 日发布了 React Native 版本 0.71.0-rc0,但此事件导致多个用户的 Android 构建失败,因为他们最终下载了错误的 React Native 版本(0.71.0-rc0 而不是他们在他们的项目,比如说 0.68.0)。

    查看链接中的所有详细信息,但我的解决方案是将下面的 configurations.all 部分添加到 android/build.gradle 文件中

    allprojects {
        repositories {...}
        configurations.all {
            resolutionStrategy {
                // Remove this override in 0.65+, as a proper fix is included in react-native itself.
                force "com.facebook.react:react-native:0.61.5"
            }
        }
    }
    

    为了更好地衡量,我还做了以下事情

    $ rm -rf node_modules
    $ cd android 
    $ rm -rf .gradle
    $ cd ..
    $ npm install
    $ react-native run-android
    

    希望这对其他人有帮助,因为我真的很难解决这个问题。

    【讨论】:

      猜你喜欢
      • 2018-03-08
      • 2019-03-21
      • 1970-01-01
      • 2021-11-25
      • 1970-01-01
      • 2020-08-12
      • 2016-07-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多