Meituan-Dianping / Robust

Robust is an Android HotFix solution with high compatibility and high stability. Robust can fix bugs immediately without a reboot.
Apache License 2.0
4.42k stars 807 forks source link

Robust 0.4.5编译transformClassesWithAutoPatchTransformForRelease问题 #159

Closed fpleihub closed 7 years ago

fpleihub commented 7 years ago

异常类型:app编译异常

Robust版本:0.4.5

Gradle版本:2.3.2

系统:Mac

堆栈/日志: 我使用0.3.3是可以编译通过生成patch.jar文件,但是使用0.4.5版本的robust生成补丁时一直报:“app:transformClassesWithAutoPatchTransformForRelease”不知为何,该有的参数我根据官方的demo来的,并且官方git clone下来demo也是一样的编译错误。 日志:

================autoPatch start================
autopatch read all class file cost 0.01 second
check all class cost 0.068 second, class count: 1611
addPatchMethodAndModifiedClass pint methodmap key is   com.demorotbusfix.MainActivity$2.onClick(android.view.View)  value is    2
key is   com.demorotbusfix.ThreeActivity.onCreate(android.os.Bundle)  value is    15
key is   com.demorotbusfix.MainActivity.handlePermissionResult()  value is    11
key is   com.demorotbusfix.MainActivity$1.onClick(android.view.View)  value is    1
key is   com.demorotbusfix.MainActivity$Callback.onPatchApplied(boolean,com.meituan.robust.Patch)  value is    6
key is   com.demorotbusfix.MainActivity.runRobust()  value is    12
key is   com.demorotbusfix.MainActivity$Callback.onPatchListFetched(boolean,boolean,java.util.List)  value is    4
key is   com.demorotbusfix.MainActivity$Callback.onPatchFetched(boolean,boolean,com.meituan.robust.Patch)  value is    5
key is   com.demorotbusfix.MainActivity$Callback.exceptionNotify(java.lang.Throwable,java.lang.String)  value is    8
key is   com.demorotbusfix.PatchManipulateImp.copy(java.lang.String,java.lang.String)  value is    14
key is   com.demorotbusfix.MainActivity$3.onClick(android.view.View)  value is    3
key is   com.demorotbusfix.MainActivity$Callback.logNotify(java.lang.String,java.lang.String)  value is    7
key is   com.demorotbusfix.MainActivity.onCreate(android.os.Bundle)  value is    9
key is   com.demorotbusfix.MainActivity.onRequestPermissionsResult(int,java.lang.String[],int[])  value is    10
key is   com.demorotbusfix.PatchManipulateImp.fetchPatchList(android.content.Context)  value is    13
:app:transformClassesWithAutoPatchTransformForRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithAutoPatchTransformForRelease'.
> java.lang.reflect.UndeclaredThrowableException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED
mivanzhang commented 7 years ago

运行gradle命令的时候加上--stacktrace

fpleihub commented 7 years ago

我这里使用注释@Add或者@Modify 都会报错,但是使用RobustModify.modify()就可以正常生成patch.jar 包,但是在加载补丁时还是出现了找不到PatchesInfoImpl这个类。我想问下,这个类在哪里?看你们的配置说robust.xml里面和PatchManipulateImp一致就可以了。 我这里是这样的:

robust.xml
<patchPackname name="patchPackname">
        <name>com.demorotbusfix.patch</name>
 </patchPackname>

PatchManipulateImp.java
....
patch.setPatchesInfoImplClassFullName("com.demorotbusfix.patch.PatchesInfoImpl");

这个类在项目里面时不存在的呀

hedex commented 7 years ago

那你改成com.meituan.robust.patch.PatchesInfoImpl试试呢?

fpleihub commented 7 years ago

改成com.meituan.robust.patch.PatchesInfoImpl这个也不行呢。

robust.xml:
<patchPackname name="patchPackname">
        <name>com.meituan.robust.patch.PatchesInfoImpl</name>
</patchPackname>

PatchManipulateImp.java
patch.setPatchesInfoImplClassFullName("com.meituan.robust.patch.PatchesInfoImpl");

加载补丁后: PatchsInfoImpl failed,cause ofjava.lang.ClassNotFoundException: Didn't find class "com.meituan.robust.patch.PatchesInfoImpl" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]

mivanzhang commented 7 years ago

你是不是补丁的位置放错了,根本没有加载到补丁?

mivanzhang commented 7 years ago

参看一下wiki https://github.com/Meituan-Dianping/Robust/wiki/%E8%A1%A5%E4%B8%81%E8%BF%90%E8%A1%8C%E9%97%AE%E9%A2%98%E6%8E%92%E6%9F%A5

fpleihub commented 7 years ago

谢谢,这个问题已经解决,补丁包加载成功,这个每次进入app都需要重新加载一次补丁包吗,这样的话这个补丁包放在sd卡中被删除就只能重新下载了。

mivanzhang commented 7 years ago

每次进入app都需要重新加载一次补丁,你可以把补丁放到私有目录,个性化定制吧