Stark
Stark is a hot-fix framework for Android. It supports swapping new implementations of classes without restarting a running Android application, and updated Android resources (icons, layout, etc) while only restarting the Android Activity.
Sample Usage
- git clone https://github.com/ximsfei/Stark.git
- cd Stark
- ./gradlew :stark-sample:clean :stark-sample:assembleDebug
- adb install -r stark-sample/build/outputs/apk/debug/stark-sample-debug.apk
- Launch sample APK.
- Fix code and resources.
Fix Code
SecondActivity.java
Fix Resources
strings.xml
Change the TextView
in activity_main.xml and activity_second.xml to Button.
- ./gradlew :stark-sample:clean :stark-sample:starkGeneratePatchDebug
- adb push stark-sample/build/outputs/apk/debug/stark-sample-debug.patch /sdcard/Android/data/com.ximsfei.stark.app/fix.apk
- Launch sample APK.
- Click the Button of applyPatch.
- Click the Button of recreate.
- Observe whether the code and resources are fixed.
Getting Started
The Gradle Dependency is available via jCenter,
Firstly, add dependency directly in your root project's build.gradle:
Secondly, apply com.ximsfei.stark
plugin and add stark core dependencies in your Android application project's build.gradle:
Note: Stark depends on jbsdiff, you need add jbsdiff dependency in your build.gradle
Initialize stark framework in application's attachBaseContext
:
After got the patch file, invoke the applyPatchAsync
method to apply patch.
After adding the dependencies and apply plugin, refresh gradle project, stark plugin will add two more tasks for you:
You can find them in the gradle stark task group.
- starkBackup + BuildType
After running the assemble + BuildType
, run the backup task can backup the files needed to generate the patch for you.
Even you can enable an automatic backup configuration in the stark.properties file.
- starkGeneratePatch + BuildType
When you find a bug in an online apk, you can fix the code and run the starkGeneratePatch + BuildType
task to generate hot-fix patch.
The starkGeneratePatch + BuildType
task relies on files backed up by the starkBackup + BuildType
task.
ProGuard
Configuration files
Also, the stark plugin will generate two configuration files in your Android application project dir:
stark.properties
stark-rules.txt