Android Studio Arctic Fox 更新后构建失败
Android Studio Arctic Fox build failed after update
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
没有更新到最新插件版本的旧应用没有这个问题。
我已经用 this solution 试过了,但没用。
我的 build.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'
}
将 Android Gradle 插件从版本 3.4.2 升级到 7.0.0(以及 Gradle 从 6 到 7)后,我也遇到了同样的错误。在我的例子中,AndroidManifest.xml
位于 resources.srcDir
指向的目录中。 Gradle 尝试将 AndroidManifest.xml
从该目录复制到已捆绑编译版本的 APK 中。
我试过你的build.gradle,删除implementation 'com.foursquare:foursquare-android-oauth:1.0.3'
后,这个问题就消失了。不知道下面出了什么问题。您只需将版本升级到 1.1.1 即可解决此问题。
在我的例子中(我将 gradle 插件从 3.6 升级到 7.1.1)我有一个 library-project 包含(旧的 vending-licensing)并且它有助于排除清单像这样(在 android{}
内):
packagingOptions {
exclude 'AndroidManifest.xml'
}
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
没有更新到最新插件版本的旧应用没有这个问题。
我已经用 this solution 试过了,但没用。
我的 build.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'
}
将 Android Gradle 插件从版本 3.4.2 升级到 7.0.0(以及 Gradle 从 6 到 7)后,我也遇到了同样的错误。在我的例子中,AndroidManifest.xml
位于 resources.srcDir
指向的目录中。 Gradle 尝试将 AndroidManifest.xml
从该目录复制到已捆绑编译版本的 APK 中。
我试过你的build.gradle,删除implementation 'com.foursquare:foursquare-android-oauth:1.0.3'
后,这个问题就消失了。不知道下面出了什么问题。您只需将版本升级到 1.1.1 即可解决此问题。
在我的例子中(我将 gradle 插件从 3.6 升级到 7.1.1)我有一个 library-project 包含(旧的 vending-licensing)并且它有助于排除清单像这样(在 android{}
内):
packagingOptions {
exclude 'AndroidManifest.xml'
}