我正在从 Android Gradle 4.1.3 升级到 7.0.2。我注意到的一件事是,对于我的 com.android.library
模块
getByName("foo") {
...
}
现在有一个接收器类型 LibraryBuildType
而不是 BuildType
它曾经。这个LibraryBuildType
不再有 isDebuggable
属性(property),其中BuildType
曾经有过。official android docs提到
If your app depends on a library module that you also want to debug, that library must also be packaged with
debuggable true
so it retains its debug symbols.
显然这些文档已经过时了,但是有什么用呢?是
debuggable true
库模块不再需要?我找到了
git log
for LibraryBuildType
,这表明它是在 2020 年 4 月左右添加的,但我在 android gradle plugin release notes 中没有找到任何相关信息
最佳答案
根据我的发现,LibraryTaskManager
的源代码仍然使用 libraryVariant.getDebuggable()
由 buildType&productFlavor 生成。我不知道为什么 debuggable
/isDebuggable
LibraryBuildType
中的选项不可用,但是如果有人正在寻找解决方法,请使用以下代码:
// library's build.gradle.kts
buildTypes {
named("debug") {
(this as com.android.build.gradle.internal.dsl.BuildType).isDebuggable = false
}
}
关于Android Gradle Plugin 7 LibraryBuildType 不再具有 isDebuggable 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69300956/