5.1的手机查看日志发现instant run是有变化的,安装的时候提示install apks,
$ adb install-multiple -r /Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/intermediates/split-apk/XIAOMI_CHANNEL/debug/slices/slice_6.apk
/Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/intermediates/split-apk/XIAOMI_CHANNEL/debug/slices/slice_5.apk
/Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/intermediates/split-apk/XIAOMI_CHANNEL/debug/slices/slice_2.apk
/Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/intermediates/split-apk/XIAOMI_CHANNEL/debug/slices/slice_1.apk
/Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/intermediates/split-apk/XIAOMI_CHANNEL/debug/slices/slice_0.apk
/Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/intermediates/split-apk/XIAOMI_CHANNEL/debug/dep/dependencies.apk
/Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/intermediates/split-apk/XIAOMI_CHANNEL/debug/slices/slice_3.apk
/Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/intermediates/split-apk/XIAOMI_CHANNEL/debug/slices/slice_4.apk
/Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/intermediates/split-apk/XIAOMI_CHANNEL/debug/slices/slice_7.apk
/Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/intermediates/split-apk/XIAOMI_CHANNEL/debug/slices/slice_8.apk
/Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/intermediates/split-apk/XIAOMI_CHANNEL/debug/slices/slice_9.apk
/Users/zhengyongxiang/Documents/gzqiaoqiao/app/build/outputs/apk/SILIAO_XIAOMI_CHANNEL_vc10_v2.6_20170304__debug.apk
Split APKs installed
由此可见新的instant run是把apk拆成多个了,需要反编译看下各个拆分出来的apk里面是什么样的,通过把slice里面的包拖到studio里面可以发现,依赖包和真正的代码会被分别编译成apk文件,变化的时候直接运行代码包,而依赖包不再运行
$ adb install-multiple -r -p com.example.zhengyongxiang.pullhead /Users/zhengyongxiang/Downloads/tinker-dev/PullHead/
app/build/intermediates/split-apk/debug/slices/slice_2.apk
Split APKs installed
$ adb shell am startservice com.mofanbaby.qiaotalk/com.android.tools.fd.runtime.InstantRunService
$ adb shell am start -n "com.mofanbaby.qiaotalk/com.mofanbaby.qiaotalk.WelcomeActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
从日志看出新的instant run多了一个InstantRunService,具体变化需要查看源码
2.3的studio多了一个小闪电标志,直接运行,发现日志是
Hot swapped changes, activity restarted
而直接点击绿色的run按钮出来的日志是这样的
03/07 10:30:17: Launching app$ adb install-multiple -r -p ...
$ adb shell am startservice ...com.android.tools.fd.runtime.InstantRunService
$ adb shell am start -n ...
Connected to process 5268 on device huawei-eva_tl00-B2T5T16620000622
由此可见小闪电对应的是之前的hot swap,而run按钮对应的是cold swap,有修改的时候先点小闪电,不生效再点绿色的那个run按钮
未完待续...