在 Android 项目中添加 FbFlipper 会出现构建错误 = processDebugManifest > Manifest merge failed

Adding FbFlipper in Android Project gives build error = processDebugManifest > Manifest merger failed

我添加了 FbFlipper 指标。我收到此错误。

Task :app:processDebugManifest FAILED /home/user/Git/my-project/app/src/main/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 element at AndroidManifest.xml:21:583-76:18 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 element at AndroidManifest.xml:21:583-76:18 to override.

更多信息:

我已将 FbFlipper Metrics 库添加为:在 build.gradle 下的依赖项中:

debugImplementation 'com.facebook.flipper:flipper:0.22.0'
debugImplementation 'com.facebook.soloader:soloader:0.6.0'

如果我 comment/remove 上面提到的行来自 build.gradle。项目构建成功并在设备上运行良好。

但是如果我添加这些行来添加 FbFlipper。它给出了构建错误。

查看 Android 清单中没有重复的 activity 名称。此外,我已将 compileSdkVersion 从 27 更新为 28,这解决了我之前的问题:

Execution failed for task ':app:processDebugResources'. Android resource linking failed

现在我将不胜感激在这方面的任何帮助,请指出我错在哪里。如何使 FbFlipper 指标在 android 项目中工作。提前致谢

我的环境详细信息:

我通过将所有支持库迁移到 AndroidX 来解决此错误。

您可以这样做:

在 gradle.build (app) 添加 sdkVersion as 28:

compileSdkVersion 28
defaultConfig {
    ......
    targetSdkVersion 28
    ......
}

同时添加这些实现以迁移到 androidx :-

implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

然后将以下两行添加到 gradle.properties:-

android.useAndroidX=true
android.enableJetifier=true

您也可以在 android 工作室以自动格式执行此操作。

  • 来自 Android Studio 中的顶部栏菜单
  • 点击重构
  • 然后从下拉列表中。点击 'Migrate to AndroidX'