[英]Manifest merger failed - android studio error
我通過Refactor > Rename
將包的名稱更改為“ com.xxx.xxx”,並將包和應用程序標識符的名稱更改為manifest
和gradle
。 同步成功,一切正常。 根據指示將delevopers.google入門和delevopers.google中級廣告內置到我的應用程序中,這些廣告先前包含在project structure
AdMob中 。 使用gradle時,嘗試在物理級別上運行該應用程序花了我很多時間。
Manifest merge error: Attribute application @ appComponentFactory value = (android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml: 22: 18-91
also present in [androidx.core: core: 1.0.0] AndroidManifest.xml: 22: 18-86 value = (androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools: replace = "android: appComponentFactory"' to the <application> element in AndroidManifest.xml: 8: 5-27: 19 to override.
如果您在gradle屬性中宣傳android.useAndroidX = true
和android.enableJetifier = true
,那么一切都會變得更糟,因為我的MainActivity.java
擴展名是AppCompatActivity
,而上面的gradle
屬性未使用它(android.useAndroidX = true)
這是因為在gradle中,您還必須將其更改為androidX並以此檢查您的依賴性
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:18.1.1'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example1.*appname*"
minSdkVersion 22
targetSdkVersion 28
versionCode 3
versionName "3.0"
**testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"**//check this is their or not
}
有時我們忘記定義testInstruement運行器
好吧,因為您沒有發布build.gradle
文件
我懷疑您擁有舊的android支持庫,並且正在嘗試遷移到AndroidX,根據您的錯誤,看來您應該改用這個
implementation "androidx.appcompat:appcompat:1.0.2"
的
implementation "com.android.support:support-compat:28.0.0"
現在,在嘗試手動修復androidx路徑之前,我還建議您將其他幾個文件以相同的方式關聯到文件,我建議您更新到最新版本的Android Studio (3.4.2)
並在其中單擊“ Migrate to AndroidX
”。重構菜單
現在有時,該錯誤可能出在您要依賴的庫中。如果是這種情況,請采用以下解決方法...
configurations {
all*.exclude module: 'support-v4' // This removes all other versions of `support-v4` if gets duplicated from all the artifacts.
api project(':your-awesome-library-goes-here')
}
如果您使用黃油刀的可能性很小
android{
.
.
// Butterknife requires Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
.
.
}
如果您仍然看到錯誤,請執行同步...然后嘗試檢查依賴項以查看哪個庫是罪魁禍首
./gradlew app:androidDependencies
app
是您模塊的名稱
干杯
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.