- 升级Gradle可以用上最新的编译优化特性
- Compose的正式版本是从AGP4.2.0开始支持的
- Android Studio Flamingo版本支持
AGP升级
build.gradle
classpath "com.android.tools.build:gradle:7.2.2"
Gradle 升级
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
so文件压缩声明
Android Gradle plugin >= 3.6.0 会默认关闭so文件的压缩
AndroidManifest.xml
<application
android:extractNativeLibs="true"
...
>
允许使用http仓库
项目构建时报错:Using insecure protocols with repositories, without explicit opt-in, is unsupported.
Switch Maven repository ‘maven(XXX)’ to redirect to a secure protocol (like HTTPS) or allow insecure protocols.
maven {
allowInsecureProtocol = true
url 'http://xxx/maven2/'
}
尽量用https的
BuildConfig
BuildConfig.APPLICATION_ID 改为 BuildConfig.BROWSER_APPLICATION_ID
BuildConfig.VERSION_CODE 改为 BuildConfig.BROWSER_VERSION_CODE
该字段已废弃
https://stackoverflow.com/questions/42205767/context-getpackagename-vs-buildconfig-application-id
https://issuetracker.google.com/issues/154275579#comment3
mapping文件丢失
旧:/apps/xx/xx/build/outputs/mapping/arm/release/mapping.txt
新:/apps/xx/xx/build/outputs/mapping/armRelease/mapping.txt
混淆问题
https://issuetracker.google.com/issues/242214899
https://issuetracker.google.com/issues/238655204
AGP7.2之后minifyEnabled=true 在debuggable=true的变体不生效
R8问题
AGP7之后没有android.enableR8 配置,无法关闭r8
新增Build Analyzer
可以方便查看编译时各个Task耗时