Android Studio Arctic Fox更新后构建失败



Android Studio更新到最新的北极狐版本,在打开一个项目后提示我更新Gradle插件,我照做了。

现在每次我尝试运行一个应用程序(与更新的插件)构建失败与下一个输出:Zip file '/home/user/path-to-my-project/app/build/outputs/apk/debug/app-debug.apk' already contains entry 'AndroidManifest.xml', cannot overwrite

未更新到最新插件版本的旧应用程序没有此问题。

我已经试过这个方法了,但是没有用。

我的构建。Gradle文件看起来像这样:

plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 30
defaultConfig {
applicationId "com.user.oauthpractice"
minSdk 27
targetSdk 30
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
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.foursquare:foursquare-android-oauth:1.0.3'
}

我尝试了您的构建。gradle,去掉implementation 'com.foursquare:foursquare-android-oauth:1.0.3'后,这个问题就解决了。不知道到底出了什么问题。您可以简单地将版本升级到1.1.1来解决这个问题。

升级Android Gradle Plugin从3.4.2版本到7.0.0(和Gradle从6到7)后,我也开始有同样的错误。在我的例子中,事实证明AndroidManifest.xml位于resources.srcDir指向的目录中。Gradle试图将AndroidManifest.xml从该目录复制到APK中,而APK中已经捆绑了一个编译版本。

在我的案例中(我将gradle插件从3.6升级到7.1.1),我包含了一个库项目(旧的vending-licensing),它有助于排除像这样的清单(在android{}中):

packagingOptions {
exclude 'AndroidManifest.xml'
}

最新更新