【问题标题】:Execution failed for task ':app:processDebugManifest' - React Native任务':app:processDebugManifest'的执行失败 - React Native
【发布时间】:2019-06-19 09:33:57
【问题描述】:

尝试在 Android 中构建 React Native 项目时收到以下错误。 解决方法如下: 1. Manifest.XML 和 android.useAndroidX=true 中的“tools:replace="android:appComponentFactory"”,android.enableJetifier=true 不起作用

> Task :app:processDebugManifest FAILED /Users/infinitesolution/Desktop/Infinite-Master/Projects/ReactNative/Ruci/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.


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.

* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

我使用的依赖项

"dependencies": {
    "lottie-react-native": "^2.6.1",
    "native-base": "^2.12.1",
    "react": "16.8.6",
    "react-native": "0.59.9",
    "react-native-admob": "^2.0.0-beta.5",
    "react-native-cardview": "^2.0.2",
    "react-native-complete-flatlist": "^1.1.34",
    "react-native-fast-image": "^6.0.3",
    "react-native-headroom": "^1.0.1",
    "react-native-loading-spinner-overlay": "^1.0.1",
    "react-native-mail": "^3.0.7",
    "react-native-reanimated": "^1.0.1",
    "react-native-router-flux": "^4.0.6",
    "react-native-scrollable-tab-view": "^0.10.0",
    "react-native-share": "^1.2.1",
    "react-native-vector-icons": "^6.5.0",
    "react-native-webview": "^5.12.0"
  },

请为此问题添加任何可能的解决方法

【问题讨论】:

    标签: android react-native


    【解决方案1】:

    过去两天一直遇到这个问题。许多其他答案提到使用react-native-device-info 更新版本。但这不适用于我的情况。

    主要原因是 google play services 和 firebase update Refer here 导致 React native 构建失败。

    我终于成功构建了,在这里我分享gist link

    如上述要点链接中所述更改了以下文件列表,

    android/build.gradle:
    build.gradle:
    gradle.properties:
    package.json
    gradle-wrapper.properties
    

    终于用上了这个包

    npm i jetifier && npx jetify
    

    完成后,最后运行

    react-native run-android
    

    并使构建成功

    提示:在尝试修复之前使用./gradlew clean。希望对您有所帮助!

    【讨论】:

    • 谢谢。我不使用设备信息。在这些步骤之后,快速图像给我带来了问题。所以我删除了 fast-image 然后它起作用了。 .
    【解决方案2】:

    刚刚在 gradle.properties 中添加:

    android.enableJetifier=true
    android.useAndroidX=true
    

    然后运行npm i jetifier &amp;&amp; npx jetify 然后运行react-native run-android 它对我有用:)

    【讨论】:

    • Jetifier 现已弃用。不工作
    猜你喜欢
    • 1970-01-01
    • 2022-01-12
    • 2021-09-10
    • 2017-10-17
    • 1970-01-01
    • 2017-11-12
    • 1970-01-01
    • 1970-01-01
    • 2022-11-08
    相关资源
    最近更新 更多