您的位置:首页 > 移动开发 > Android开发

Android 平台上的秒级编译方案 - Freeline

2017-03-02 00:53 363 查看
Freeline是什么?

Freeline是蚂蚁金服旗下一站式理财平台蚂蚁聚宝团队15年10月在Android平台上的量身定做的一个基于动态替换的编译方案,5月阿里集团内部开源,稳定性方面:完善的基线对齐,进程级别异常隔离机制。性能方面:内部采用了类似Facebook的开源工具buck的多工程多任务并发思想:端口扫描,代码扫描,并发编译,并发dx,并发merge dex等策略,在多核机器上有明显加速效果,另外在class及dex,resources层面作了相应缓存策略,做到真正增量开发,另外引入并优化buck的部分加速组件dx,DexMerger,资源编译方面,深入改造了Aapt资源编译流程,当资源发生改变时候,秒级完成增量包编译,其中增量包仅含最小的变更集合(10Kb~数百Kb内),后期也被运用到线上进行资源/代码动态替换。相比目前instant-run,buck,layoutcast等方案快数倍速度。

项目地址:https://github.com/alibaba/freeline

使用教程

工具

Android Studio + Python环境

配置

project-build.gradle:

buildscript {

repositories {

jcenter()

}

dependencies {

classpath ‘com.antfortune.freeline:gradle:0.8.6’

}

}

module’s build.gradle:

apply plugin: ‘com.antfortune.freeline’

1

1

注:以上配置只是追加上去就行,不用把gradle相关的去除。

dependencies {

debugCompile ‘com.antfortune.freeline:runtime:0.8.6’

releaseCompile ‘com.antfortune.freeline:runtime-no-op:0.8.6’

testCompile ‘com.antfortune.freeline:runtime-no-op:0.8.6’

}

android {



freeline {

hack true

productFlavor “znds”

autoDependency false

}

}

插件安装

studio中安装插件:Freeline Plugin。安装后工具栏,如图:

这里写图片描述

代码植入

Application中植入代码:

public void onCreate() {

FreelineCore.init(this);

super.onCreate();



}

之后,点击工具栏上的那个蓝色按钮,就可以运行项目了。

参考资料:

Freeline - Android平台上的秒级编译方案 —— https://yq.aliyun.com/articles/59122
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 开源工具