【问题标题】:React-native error: Manifest merger failedReact-native 错误:清单合并失败
【发布时间】:2019-07-10 19:15:54
【问题描述】:

运行我的应用时出现此错误:

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

我已经尝试添加到 gradle.properties

android.useAndroidX=true
android.enableJetifier=true

还有(到 AndroidManifest)

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

还有(构建.gradle)

implementation "androidx.appcompat:appcompat:1.0.0"

替换之前的

implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"

但不适合我。

-- Android Manifest.xml --

<uses-permission android:name="android.permission.INTERNET" />

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

-- build.gradle--

dependencies {
    implementation project(':react-native-exit-app')
    implementation project(':react-native-firebase')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompatv7:
 ${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation "com.google.firebase:firebase-core:17.0.0"
    implementation 'com.google.firebase:firebase-auth:18.0.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'
}

【问题讨论】:

标签: android react-native android-appcompat androidx


【解决方案1】:

这意味着您的一个库正在使用 AndroidX。因此,您必须将您的应用转换为 AndroidX。

  • android.useAndroidX=true android.enableJetifier=true 将这些行放在你的 gradle.properties 中。
  • npm install --save-dev jetifier
  • npx jetify
  • npx react-native run-android(您的应用应该可以正确编译和运行)
  • 在你的 package.json 的 postinstall 目标中调用 npx jetify run(任何时候你的依赖更新你都必须再次 jetify)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-04
    • 2021-12-16
    • 2015-03-21
    • 2021-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多