Getting started with JRebel for Android

介绍

无意中发现zeroturnaround公司发布了一神器JRebel for Android,仅支持Android Studio,虽然这个JRebel for Android 目前来看功能还是比较有限的,主要作用就是类和UI的改动能够自动reload无需从新安装运行apk,已经算是大大的提高了工作效率,以及Android studio 2.0之后google发布的 Instant Run两者的区别
One thing you can try is JRebel for Android. It takes a different approach by not introducing a new apk after each change. Instead apk gets installed once and delta packages are shipped over to the device or emulator and are applied during runtime. This logic is nothing new and has been present in the Java EE/SE with JRebel for more than 8 years.
Let’s take the Google IO 2015 app and see how the JRebel for Android setup works as well as how it can save you valuable time.

安装

打开Android Studio -> Preferences -> Plugins -> Browse repositories… -> Search “JRebel for Android” -> Install plugin 安装好后重启导入证书即可 安装
这里写图片描述

使用方法

用法很简单,就是原本的Run和Debug按钮替换成JRebel的Run和Debug按钮,看动画就可以理解 使用方法 有个地方需要注意的是就是每次修改完后要手动点Make按钮(或者快捷键是Command+F9)模拟器那边的程序才会重新渲染
这里写图片描述

Why should I try JRebel for Android?

  • There are loads of reasons! Here are some of the most persuasive reasons as to why you should give it a go:
    • Reduce the time it takes to see your changes on the device
    • Polishing UI and getting that pixel perfect result no longer takes hours because of long build times
    • No need to change anything in your project to make JRebel for Android work
    • Use debugger and update code and resources at the same time! That’s right JRebel for Android comes with full debugger support!

比对JRebel 和Android Instant Run两者的区别:这里写链接内容how to update code and resources in Android application without wasting time on restarts.

两者的共同点都是Swapping code

Both Instant Run and JRebel for Android are all about “swapping” code or resources, live, inside a runtime environment. This means that you install the APK just once. When the APK is present on the target device, you can start sending over small, incremental patches that will be applied.
This is a huge timesaver in a multitude of ways:
The build process no longer needs to package and build the code parts that have not changed — just rebuild the deltas.
Less data needs to be pushed to the device over ADB.
Once on the device, the dex2oat has a lot less work to do, compared to a full APK install.

Hot, warm, and cold swap

Here is the short version, code changes are handled this way:
  • Hot Swap — New code is executed in the next call.
  • Warm Swap — New code is executed after the activity restarts.
  • Cold Swap — New code is executed after the application restarts.
Changes to resources have fewer options:
  • Warm Swap — New resources are used after the activity restarts.
  • Cold Swap — New resources are used after the application restarts.

Comparing JRebel for Android and Instant Run

当你update code 运行到设备时:Instant Run的执行过程是perform a hot or warm swap这关键决定在于Android studio

 This depends on the Android Studio > Preferences > Build, Execution, Deployment > Build Tools > Instant Run “Restart activity on code changes” setting

JRebel 没有“Restart activity on code changes” setting,改变code 和resource都是执行warm swap。

JRebel for Android does not have a separate “Restart activity on code changes” setting. Code and resource changes will always be handled by a warm swap. This is an acknowledged user experience decision that we made a long time ago. The main reason for why JRebel for Android does not “hot swap” is to make it easier for the user to understand what is happening — and what to expect after code or resources have been updated.

详细查看原文:https://medium.com/@shelajev/getting-started-with-jrebel-for-android-426633cde736#.qes7gy8za

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值