阿里巴巴旗下 Android 平台上的秒级编译方案 - Freeline
2017-03-06 17:16
417 查看
下面这段引自:Freeline 在 Github 的原理介绍
Freeline 是 Android 平台上的秒级编译方案,Instant Run 的替代品,也可以从 Freeline 官方主页来获取更多的信息。
Freeline 由蚂蚁聚宝 Android 团队开发,它可以充分利用缓存文件,在几秒钟内迅速地对代码的改动进行编译并部署到设备上,有效地减少了日常开发中的大量重新编译与安装的耗时。
Freeline能够为Android开发者节省很多喝杯咖啡的时间 : )
下面是我总结的Freeline的安装使用步骤:
安装 FreeLine插件 ;AndroidStudio—>Preferences—>Plugins—>Browse—>Repositories—> 搜索 FreeLine —>找到FreeLine Plugin—> 安装—>安装完毕重启。安装完毕后会有一个蓝色的图标
下载相关内容
找到工程级的build.gradle
找到你的module的build.gradle;添加下面的配置
找到 AndroidStudio 底部的 Terminal ;输入以下命令,用来下载依赖内容:
如果你遇到了下面
:initFreeline FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:initFreeline’.
java.net.ConnectException: Operation timed out
Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.
BUILD FAILED
那么就执行下面的命令:
静静的等待它执行完毕,就OK了。
在你的module的 Application 类里添加下面的代码:
关于这一步我刚开始没有使用也正常的运行了,大家可以多试试,我也刚开始研究
准备已经完毕,你就可以像使用AndroidStudio普通的运行方式一样来用Freeline了
选中你要运行的module,点击代表Freeline的蓝色图标
这样就开始运行了。之后你会看到在下部Freeline控制台会打印出执行的过程,类似于下图:
注意:
Freeline只能在application里使用, 不能在 library里使用
Freeline只能在同一工程下的 一个module里使用;如果你有两个module,需要注释掉 其中一个module里的这一行 groovy 代码
如果你的项目已经运行了,并且在手机上是打开的它会更新你的APP,并保持之前的状态;如果你的应用退出了,它则只会更新程序,更新完毕后,需要你手动点开。
上面的问题是我在使用过程中发现的,如果有其它问题可以参看下面的常见问题
Freeline常见问题
Freeline GitHub issues
Freeline 是 Android 平台上的秒级编译方案,Instant Run 的替代品,也可以从 Freeline 官方主页来获取更多的信息。
Freeline 由蚂蚁聚宝 Android 团队开发,它可以充分利用缓存文件,在几秒钟内迅速地对代码的改动进行编译并部署到设备上,有效地减少了日常开发中的大量重新编译与安装的耗时。
Freeline能够为Android开发者节省很多喝杯咖啡的时间 : )
下面是我总结的Freeline的安装使用步骤:
安装 FreeLine插件 ;AndroidStudio—>Preferences—>Plugins—>Browse—>Repositories—> 搜索 FreeLine —>找到FreeLine Plugin—> 安装—>安装完毕重启。安装完毕后会有一个蓝色的图标
下载相关内容
找到工程级的build.gradle
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath 'com.antfortune.freeline:gradle:0.8.6'//FreeLine插件 } }
找到你的module的build.gradle;添加下面的配置
apply plugin: 'com.android.application' apply plugin: 'com.antfortune.freeline'//FreeLine的插件
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:25.1.1' compile 'com.android.support:support-v4:25.1.1' //这里是FreeLine的依赖库 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' }
找到 AndroidStudio 底部的 Terminal ;输入以下命令,用来下载依赖内容:
./gradlew initFreeline
如果你遇到了下面
:initFreeline FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:initFreeline’.
java.net.ConnectException: Operation timed out
Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.
BUILD FAILED
那么就执行下面的命令:
./gradlew initFreeline -Pmirror
静静的等待它执行完毕,就OK了。
在你的module的 Application 类里添加下面的代码:
@Override public void onCreate() { FreelineCore.init(this);//必须要在onCreate方法的第一行 super.onCreate(); }
关于这一步我刚开始没有使用也正常的运行了,大家可以多试试,我也刚开始研究
准备已经完毕,你就可以像使用AndroidStudio普通的运行方式一样来用Freeline了
选中你要运行的module,点击代表Freeline的蓝色图标
这样就开始运行了。之后你会看到在下部Freeline控制台会打印出执行的过程,类似于下图:
注意:
Freeline只能在application里使用, 不能在 library里使用
Freeline只能在同一工程下的 一个module里使用;如果你有两个module,需要注释掉 其中一个module里的这一行 groovy 代码
apply plugin: 'com.antfortune.freeline'
然后再运行;否则会报下面的错 > Cannot add task ':initFreeline' as a task with that name already exists.
如果你的项目已经运行了,并且在手机上是打开的它会更新你的APP,并保持之前的状态;如果你的应用退出了,它则只会更新程序,更新完毕后,需要你手动点开。
上面的问题是我在使用过程中发现的,如果有其它问题可以参看下面的常见问题
Freeline常见问题
Freeline GitHub issues
相关文章推荐
- Freeline - Android平台上的秒级编译方案
- Freeline - Android平台上的秒级编译方案
- Android 平台上的秒级编译方案 - Freeline
- Freeline - Android平台上的秒级编译方案
- Android 平台上的秒级编译方案 - Freeline
- Android 平台上的秒级编译方案 Freeline(蚂蚁聚宝团队开源)
- Freeline - Android平台上的秒级编译方案
- Freeline - Android平台上的秒级编译方案,让你的app编译快10倍
- Freeline - Android平台上的秒级编译方案
- Freeline--Android平台上的秒级编译方案
- Freeline - Android平台上的秒级编译方案
- Freeline - Android平台上的秒级编译方案
- Freeline - Android平台上的秒级编译方案
- Android 平台上的秒级编译方案 - Freeline
- Freeline - Android平台上的秒级编译方案
- ANDROID 秒级编译 FREELINE
- Android 秒级编译 Freeline
- Freeline比instant-run更好用的Android增量编译方案及常见问题
- Android编译Lame的全平台so库方案2,并实现转码mp3
- 使用秒级编译方案-Freeline