正在制作有关 LiveData 和 ViewModel 的教程。 在 build.gradle 中我添加了:
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
项目同步没有问题。然后我添加了(1):
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.0.0"
但是同步失败所以我添加了(2)(我安装了 Java 10.0.2):
// alternately - if using Java8, use the following instead of lifecycle-compiler
implementation "androidx.lifecycle:lifecycle-common-java8:2.0.0"
但我得到了同样的 list 合并失败错误:
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:6:5-28:19 to override.
添加到 Android list :
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:appComponentFactory">
同步失败:
java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs
最佳答案
这是因为您没有正确设置项目以使用 Android 的新 AndroidX 支持库。参见 AndroidX .最快的解决方案是使用 LiveData deps 中显示的 pre-androidx 依赖项.否则请引用前面的链接在您的项目中正确设置 AndroidX。这可以很容易地通过添加 android.useAndroidX=true 来完成
android.enableJetifier=true
进入你的 gradle.properties。这些会导致编译器将 android 支持库转换为相应的 AndroidX 库。
关于android - 添加 : annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.0.0" 后 list 合并失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53246308/