【问题标题】:How to fix Execution failed for task ':app:processDebugManifest' in React Native?如何修复 React Native 中任务“:app:processDebugManifest”的执行失败?
【发布时间】:2019-06-18 07:47:42
【问题描述】:

我在运行项目时发现一个错误,我尝试寻找很多示例但都失败了,这是错误的详细信息:

D:\myApp\android\app\src\debug\AndroidManifest.xml:22:18-91 Error:
        Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
        is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


> Task :app:processDebugManifest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
        is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.

请任何人帮我解决这个问题。

谢谢

【问题讨论】:

    标签: android android-studio react-native gradle android-manifest


    【解决方案1】:

    所以我在安装react-native-reanimated 以使react-navigation-drawer 正常工作时遇到了这个问题。

    解决方法是:

    1. 添加到 android/gradle.properties:
    android.enableJetifier=true
    android.useAndroidX=true
    
    1. yarn add jetifier

    2. 在 android 目录下运行: ./gradlew clean

    3. 运行: yarn jetify

    4. react-native run-android

    我的 RN 版本 0.59.8

    【讨论】:

    • 对我不起作用被困在这 2 天不断显示> 任务:app:processDebugMainManifest FAILED
    • 也许从那以后发生了一些变化......
    • 将 build.gradle 文件中的构建工具版本设置为 buildToolsVersion = "23.0.1" 对我有用
    【解决方案2】:

    将“react-native-device-info”升级到版本 2.1.2 为我修复了该错误。 见http://github.com/facebook/react-native/issues/25294#issuecomment-503024749

    【讨论】:

      【解决方案3】:

      2 天后终于找到了解决方案,并在 android/build.gradle 中添加了以下两行

      googlePlayServicesVersion = "16.+"

      firebaseVersion = "17.3.4"

      【讨论】:

      • 这些文件会放在哪里?
      【解决方案4】:

      我还有一些依赖 gcm 的库(除了 deviceinfo),所以我用它来解决问题:https://stackoverflow.com/a/56648987/8306924

      【讨论】:

        【解决方案5】:

        您只需编辑“gradle.properties”并添加:

        android.useAndroidX=true
        android.enableJetifier=true
        

        所以你解决了 google 和第三方依赖之间的依赖冲突。

        【讨论】:

          【解决方案6】:

          我将 java 版本从 17 降级到 15 并且它可以工作

          【讨论】:

            【解决方案7】:

            我遇到了同样的问题并在 android 上更改了 gradle 的版本 > build.gradle 并修复了我的问题

            classpath("com.android.tools.build:gradle:4.2.2")
            

            classpath("com.android.tools.build:gradle:7.1.1")
            

            清理 gradle 并重新构建

            在android目录命令提示符下:

            #gradlew clean
            #gradlew build
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2021-04-09
              • 2022-01-12
              • 2019-02-26
              • 2017-12-20
              • 2021-09-10
              • 1970-01-01
              • 1970-01-01
              • 2017-10-17
              相关资源
              最近更新 更多