我已经迁移到 gradle 8 我的 android 构建 gradle 文件显示
plugins {
id 'com.android.application' version '8.1.0-alpha01' apply false
id 'com.android.library' version '8.1.0-alpha01' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
id 'com.google.dagger.hilt.android' version '2.44.2' apply false
}
tasks.register('clean') {
delete rootProject.buildDir
}
现在,在我的模块 gradle.build 文件中,packagingOptions 突出显示为已弃用
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
我以为我已经找到了这个解决方案
packagingOptions {
resources.excludes.add('/META-INF/{AL2.0,LGPL2.1}')
}
这是行不通的!
已弃用的 PackagingOptions 排除的正确替代品是什么?
我使用的android studio版本是
Android Studio Giraffe | 2022.3.1 Canary 1
Build #AI-223.4884.69.2231.9486165, built on January 13, 2023
Runtime version: 17.0.5+0-17.0.5b653.23-9410051 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.6.1
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 12
Metal Rendering is ON
Registry:
external.system.auto.import.disabled=true
ide.text.editor.with.preview.show.floating.toolbar=false
ide.images.show.chessboard=true
Non-Bundled Plugins:
com.android.aas (3.5.1)
这似乎可以修复它
packagingOptions.resources.excludes.add('/META-INF/{AL2.0,LGPL2.1}')