如何删除清单合并错误
How can i remove manifest merge errors
我将 MaterialAlertDialog 添加到我未使用 androidx 的项目中。这在下一次构建期间导致了错误。所以我从应用程序级别构建 gradle 中删除了 'implementation' 语句。但是当我尝试构建我的项目时,我仍然遇到明显的合并错误。
这是我在构建时遇到的错误
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:19:5-152:19 to override.
到目前为止我已经尝试了以下解决方案,关闭并重新加载我的项目。清理并重建。删除我项目中的 .gradle 和 .idea 文件夹并重新构建它
这些是我项目中的依赖项
dependencies
{
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "com.android.support:appcompat-v7:${android_support_version}"
implementation "com.android.support:design:${android_support_version}"
implementation 'com.github.lzyzsd:circleprogress:1.1.0@aar'
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1@aar'
implementation 'commons-net:commons-net:3.3'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true
}
implementation "de.hdodenhof:circleimageview:${circle_imageview}"
implementation "com.github.bumptech.glide:glide:${glide_version}"
implementation "com.android.support:recyclerview-v7:${android_support_version}"
implementation "com.android.support:cardview-v7:${android_support_version}"
implementation "com.squareup.retrofit2:retrofit:${retrofit_service_version}"
implementation "com.squareup.retrofit2:converter-gson:${retrofit_gson_convertor}"
implementation "com.clough.android.androiddbviewer:androiddbviewer:${dbviewer_version}"
implementation "com.android.support:multidex:${multidex_version}"
implementation "com.github.crosswall:Android-Coverflow:${viewPager_version}"
implementation "com.squareup.okhttp3:logging-interceptor:3.4.0"
implementation project(':sdkui')
implementation 'com.github.ronaldsmartin:Material-ViewPagerIndicator:1.0.4'
implementation 'com.google.android.gms:play-services-base:16.0.1'
implementation 'com.google.android.gms:play-services-identity:16.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'
implementation 'com.google.firebase:firebase-config:16.1.0'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
}
apply plugin: 'com.google.gms.google-services'
在您的清单文件中添加这些行。
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
清单文件
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="false"
android:theme="@style/AppTheme"
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString">
试试这个
使用 Android Studio 3.2 及更高版本,您可以通过选择 Refactor > Migrate to AndroidX[= 快速迁移现有项目以使用 AndroidX 21=] 从菜单栏。
如果您有任何尚未迁移到 AndroidX 命名空间的 Maven 依赖项,当您将以下两个标志设置为 true 时,Android Studio 构建系统也会为您迁移这些依赖项在您的 gradle.properties 文件中:
android.useAndroidX=true
android.enableJetifier=true
在 Application TAG 的 Manifest 文件中添加这些行。
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
我回答这个问题只是为了说明解决我的问题所采取的步骤。
- 我删除了 MaterialDesign 的 gradle 依赖项。
- 缓存问题已通过执行文件-> 使缓存无效并重新启动得到解决
由于 Firebase 在重启前更改为版本 20,问题仍然存在。
将 Firebase 版本降低到 17.3.4 这修复了所有问题。
我将 MaterialAlertDialog 添加到我未使用 androidx 的项目中。这在下一次构建期间导致了错误。所以我从应用程序级别构建 gradle 中删除了 'implementation' 语句。但是当我尝试构建我的项目时,我仍然遇到明显的合并错误。
这是我在构建时遇到的错误
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:19:5-152:19 to override.
到目前为止我已经尝试了以下解决方案,关闭并重新加载我的项目。清理并重建。删除我项目中的 .gradle 和 .idea 文件夹并重新构建它
这些是我项目中的依赖项
dependencies
{
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "com.android.support:appcompat-v7:${android_support_version}"
implementation "com.android.support:design:${android_support_version}"
implementation 'com.github.lzyzsd:circleprogress:1.1.0@aar'
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1@aar'
implementation 'commons-net:commons-net:3.3'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true
}
implementation "de.hdodenhof:circleimageview:${circle_imageview}"
implementation "com.github.bumptech.glide:glide:${glide_version}"
implementation "com.android.support:recyclerview-v7:${android_support_version}"
implementation "com.android.support:cardview-v7:${android_support_version}"
implementation "com.squareup.retrofit2:retrofit:${retrofit_service_version}"
implementation "com.squareup.retrofit2:converter-gson:${retrofit_gson_convertor}"
implementation "com.clough.android.androiddbviewer:androiddbviewer:${dbviewer_version}"
implementation "com.android.support:multidex:${multidex_version}"
implementation "com.github.crosswall:Android-Coverflow:${viewPager_version}"
implementation "com.squareup.okhttp3:logging-interceptor:3.4.0"
implementation project(':sdkui')
implementation 'com.github.ronaldsmartin:Material-ViewPagerIndicator:1.0.4'
implementation 'com.google.android.gms:play-services-base:16.0.1'
implementation 'com.google.android.gms:play-services-identity:16.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'
implementation 'com.google.firebase:firebase-config:16.1.0'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
}
apply plugin: 'com.google.gms.google-services'
在您的清单文件中添加这些行。
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
清单文件
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="false"
android:theme="@style/AppTheme"
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString">
试试这个
使用 Android Studio 3.2 及更高版本,您可以通过选择 Refactor > Migrate to AndroidX[= 快速迁移现有项目以使用 AndroidX 21=] 从菜单栏。
如果您有任何尚未迁移到 AndroidX 命名空间的 Maven 依赖项,当您将以下两个标志设置为 true 时,Android Studio 构建系统也会为您迁移这些依赖项在您的 gradle.properties 文件中:
android.useAndroidX=true
android.enableJetifier=true
在 Application TAG 的 Manifest 文件中添加这些行。
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
我回答这个问题只是为了说明解决我的问题所采取的步骤。
- 我删除了 MaterialDesign 的 gradle 依赖项。
- 缓存问题已通过执行文件-> 使缓存无效并重新启动得到解决
由于 Firebase 在重启前更改为版本 20,问题仍然存在。
将 Firebase 版本降低到 17.3.4 这修复了所有问题。