BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News ZeroTurnaround Announces JRebel for Android 1.0

ZeroTurnaround Announces JRebel for Android 1.0

This item in japanese

ZeroTurnaround has announced the first stable release of JRebel for Android, the Android version of their popular plugin to modify running applications without having to redeploy or restart. JRebel for Android is available for Android Studio from the JetBrains plugin repository, and supports all phones and tablets running Android 4.0 or later. ZeroTurnaround offers a 21-day free trial, with prices beginning at $49/year.

A common complaint from Android developers is how the underlying technology imposes a rather slow feedback loop. Every time a developer wants to see the effect of a code change, the Android application needs to be recompiled, repackaged, reinstalled into the Android device and restarted. On top of the delay that this process entails, if the feature being modified is a few steps down a particular workflow, the developer will have to walk through such workflow every time a change is deployed. For this reason, a hot swap functionality has been requested by the development community for at least two years.

To fill this need, ZeroTurnaround started work on JRebel for Android in 2014, producing a beta version in April 2015. With the feedback from the beta program, an early access release was made available in September 2015. The JRebel for Android plugin will add new items to the Run menu in Android Studio and modify the Gradle build file to include the tools that allow the code to be hot swapped into the running application. A demonstration of how this works can be seen in the following video.


JRebel for Android in Action from Official ZeroTurnaround Account on Vimeo.

Technical details

Despite providing analogous functionality, the different underlying technologies mean that traditional JRebel and JRebel for Android work in rather different ways. In the case of JRebel, code changes in Java would be compiled, and the resulted bytecode inserted into the running web application through class reloading. Android, on the other hand, doesn't even use a Java Virtual Machine: until Android 4.0, Java code was compiled into DEX files, which were then interpreted by the Dalvik virtual machine (after the necessary packaging and installation); from Android 5.0 onwards, the DEX files are then recompiled to native machine code by the device itself; therefore a different approach was needed.

As ZeroTurnaround explains, JRebel for Android modifies the project's Gradle build to create a shell APK which only contains the JRebel for Android agent; this is the only APK that needs to be installed in the Android device being used for development. Then the actual application (DEX files and resources) are sent to the agent via ADB, and the agent loads them as the running app. Upon modification, the relevant DEX files are rebuilt and sent to the agent, together with modified resources, without having to recreate or reinstall a new APK.

To reload changes on the fly the agent will call Activity.recreate for the top-most activity in the stack. This means that onCreate, onStart, onResume will be invoked. As a result, the developer needs to handle onSaveInstanceState appropriately in order for the application to reload exactly where it was.

The JRebel for Android agent will only present while developing, when a formal release is prepared the APK will only contain the relevant DEX files and resources.

Alternatives

Given the high demand from the community for this kind of application, there have been a number of tools similar to JRebel for Android released over the last years. Although none of the tools investigated by InfoQ are as feature-complete as JRebel, they are worth mentioning since they may suit some particular needs.

Buck (Exopackage): Created by Facebook, it requires changes in the application to make it work. Free to use.

Mirror: Only useful for quick edition of layouts, unable to push code to the device. Licenses available from $79 as a one-off payment. Free 30-day trial. 

Live Development Tasks in Intel XDK: Intel XDK is an IDE to develop hybrid HTML5 applications based on Cordova, it doesn't support native Android applications. Free to use.

Android Design Preview: Tool that simply mirrors a portion of desktop into an android device; it doesn't support in-device interaction, but it can provide a quick way to test layouts. Free.

LayoutCast: Still in early stages of development, and therefore with limited functionality and stability issues. Only works with Android 5 or later. Free.

Rate this Article

Adoption
Style

BT