android - 清单合并失败如何解决
问题描述
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:5:5-19:19 to override.
这个错误怎么解决。。
解决方案
分级文件
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "com.niks.abc" minSdkVersion 15 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50" implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.core:core-ktx:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' }
不要忘记添加
android.useAndroidX=true android.enableJetifier=true
到你的 gradle.properties。当我上一台新机器时,我总是忘记这一点,因为 gradle.properties 不在源代码管理中。如果我们在这种情况下得到一个合理的错误,那就太好了。
显现:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.niks.abc"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
希望这对您有足够的帮助。
推荐阅读
- c# - 如何使用多线程每 5 分钟调用多个方法
- python - Django自定义用户模型问题
- c# - 从 WebBrowser 控件向父应用程序发送消息
- html - 布局:左侧固定文本框,右侧可滚动 MDL 卡
- android - java.io.IOException:无法创建 PTY
- azure - Terraform azurerm_kubernetes_cluster 无效或未知密钥:network_profile
- python - CSS 中的图像不使用 Flask 加载
- php - 最小数量验证器在 Yii2 模型中不起作用
- c# - 东亚本地化软件中的访问/快捷键?
- c - How can geometric algebra blades be implemented in c?