关于它的介绍,【Android开发者】公众号今天发文了,我就直入主题吧
引入依赖
app的build.gradle中添加依赖:
implementation "androidx.profileinstaller:profileinstaller:1.2.0"
gradle.properties 中添加以下内容
# Enable adding baseline-prof.txt files to AAR artifacts, and binary profiles to APKs
android.experimental.enableArtProfiles=true
添加baseline-prof.txt文件
APP的AndroidManifest.xml同级目录添加baseline-prof.txt文件
该txt文件规则见地址:developer.android.google.cn/jetpack/and…
但也可以简单使用:
如:我apk所有类和文件都在该包下:com.my.myapplication
则我可以文件中添加一行
Lcom/my/myapplication/*;
那么,仅release包中,我apk的所有类都将在安装时执行AOT编译。 从而可以优化启动速度,拖慢安装速度
更多精准优化到具体方法的语法将在文后补全,或者你也可查看上方链接。