HotFix?Deprecated?
??? RocooFix
??????? RocooFix??????Nuwa??Gradle1.40 ?Transform API????????????Gradle1.3-Gradle2.1.0??
??App?????????
##?? ??????QQ???????????????????????????????
????? ??App???????????
??????? dalvik_patch ???????????????????multidex??????????????????
??????????????????????????????
????Github: jiqimaogou
????: Nuwa ?????????????????????????
##???? ###???? ???????????????ClassLoader??????????????????????????????????????
??????????? dodola.hotfix.BugClass
???????
public class BugClass {
public String bug() {
return "bug class";
}
}
???? BugClass
??? bug()
???????????????????
public class BugClass {
public String bug() {
return "fixed class";
}
}
???????????????????dex??
?????
-
?class??????jar??
jar cvf path.jar *
-
?jar????dex?jar?
dx --dex --output=path_dex.jar path.jar
????????? path_dex.jar
###??javassist??????
??????????????????????
java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
??????????????????
??????????????????????????????????clazz?????dex?????????????? CLASS_ISPREVERIFIED
????????????????????dex????????????????????????dex???????????????????????????????????dex???????????????????
????????????dex????? hackdex
?????????????? AntilazyLoad
??????????????????
?????????dex?jar????????????
?????????? javassist
?????????????????????
????????????????Gradle?Task???? buildSrc
??
???????Groovy????????Groovy SDK????????
???????
/**
* ????
* @param buildDir ????build class??,?????????class???
* @param lib ???hackdex???,??AntilazyLoad??class?????
*/
public static void process(String buildDir, String lib) {
println(lib)
ClassPool classes = ClassPool.getDefault()
classes.appendClassPath(buildDir)
classes.appendClassPath(lib)
//???????????,????????????????????
CtClass c = classes.getCtClass("dodola.hotfix.BugClass")
println("====??????====")
def constructor = c.getConstructors()[0];
constructor.insertBefore("System.out.println(dodola.hackdex.AntilazyLoad.class);
")
c.writeFile(buildDir)
CtClass c1 = classes.getCtClass("dodola.hotfix.LoadBugClass")
println("====??????====")
def constructor1 = c1.getConstructors()[0];
constructor1.insertBefore("System.out.println(dodola.hackdex.AntilazyLoad.class);
")
c1.writeFile(buildDir)
growl("ClassDumper", "${
c.frozen
}
")
}
??????????????????????task?????
? app ??? build.gradle ???????
task('processWithJavassist') << {
String classPath = file('build/intermediates/classes/debug')//????class????
dodola.patch.PatchClass.process(classPath, project(':hackdex').buildDir
.absolutePath + '/intermediates/classes/debug')//??????hackdex?class????
}
android{
.......
applicationVariants.all {
variant ->
variant.dex.dependsOn << processWithJavassist //???dx??????????class?
}
}
???????apk?????????????????????? dodola.hackdex.AntilazyLoad
???
###????????
##???? ?????????????
- ????????????????????????????class???md5?????mapping?????
- ?????????-applymapping??????????mapping?????????????class???md5???????????????class?????????
??????????????????????mapping???????????????mapping???????????????????????
?????????????????
##ISSUE
- ???????????????????????????????????????????????????????????????????????????????
- ??????????????
Class ref in pre-verified class resolved to unexpected
??????????????