Small
Small copied to clipboard
Support for Android Gradle Plugin 3.0
Android Gradle Plugin
(下称 AGP) 3.0 相对于 2.3.0 有了大幅的 API 改动。
导致我们的 gradle-small
编译插件在以下重要环节出现了问题:
- 解析 aar 依赖
- 分离 class
- 分离 arsc
- 分离 JNI
- 分离 manifest
- 分离 assets
为解决该适配问题,Small 决定重新设计编译流程,前置分离过程,减少不必要的后期 transform hook。同时彻底弃用原有对 AGP 私有 API 的引用,为以后兼容性打下基础。
拟采取以下方案(打钩项目已完成):
- [x] 1. 预处理:解析 aar 依赖,对等构造一批仅包含
res
目录的 aar 文件,提前完成Jar
,JNI
,Manifest
,Assets
等文件分离 - [x] 2. 重定向:通过动态构造 flatDir repo,引用上述裁剪版的 aar 依赖
- [x] 3. 分离三方库:根据 (1) 中依赖,动态
compileOnly
当前插件模块所需的jar
- [x] 4. 分离
R.class
:通过对aapt
,javac
task 的 hook,构造一个仅含当前模块所需的R.class
- [x ] 5. 分离
ap_
:解压ap_
文件,分离非模块自身的res
资源,并重新构造一个经过剪裁的arsc
文件 - [ ] 6. 混淆适配
方案改造后,将完美适配 AGP 3.0。 同时新方案将大量的 I/O 操作前置到预处理过程,并良好地利用 Gradle Task Up-To-Date 设计,预期将大幅提高编译效率。
最新进展
目前已完成初步适配,代码分支 support-android-gradle-3.0
赞!👍 加油!
那如果只是升级Android studio 版本为3.0,不升级Android Gradle Plugin 或 gradle 版本,编译应该不会受影响吧?
@navyifanr 不会
适配gradle plugin 3.0以上的了吗?
@podinns @wkable 已初步适配,见分支 support-android-gradle-3.0
@galenlin As per your reply to #570 and The initial adaptation has now been completed given in latest update, What it means? If this means that now I can use 3.0.0 Gradle plugin version instead of 2.3.0 in my project. In that case, I made following changes in Application level build.gradle file as below
dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath 'net.wequick.tools.build:gradle-small:2.0.0' } then I got following error "could not find net.wequick.tools.build:gradle-small:2.0.0"
When I make changes as below dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath 'net.wequick.tools.build:gradle-small:1.3.0-beta6' }
then I got the following error "Could not get unknown property libraries for task :app.*:processDebugManifest"
Please give clarification that,either this adaption work still in progress or am I missing some thing.
@kumarswamy-repo Yes, it's incubating, you can checkout the support-android-gradle-3.0
branch and try the DevSample
source project.
@kumarswamy-repo Yes, it's incubating, you can checkout the
support-android-gradle-3.0
branch and try theDevSample
source project.
support-android-gradle-3.0 DevSample分支跑不起来: 报错:You need to use a Theme.AppCompat theme (or descendant) with this activity。我已经将Theme适配还是不行。 AS:3.0 gradle:3.0.1
@kumarswamy-repo Yes, it's incubating, you can checkout the
support-android-gradle-3.0
branch and try theDevSample
source project.support-android-gradle-3.0 DevSample分支跑不起来: 报错:You need to use a Theme.AppCompat theme (or descendant) with this activity。我已经将Theme适配还是不行。 AS:3.0 gradle:3.0.1
metoo