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.43k stars 809 forks source link

新增类后打包失败,但修改方法打包成功 #451

Closed zhanf closed 3 years ago

zhanf commented 3 years ago

@achellies @zztztt @cyndibaby905

修改/新增 方法 生成patch包成功,新增类 生成patch包失败!

异常类型:app运行时异常/编译异常

Robust版本:0.4.99

Gradle版本:3.6.3

Jdk:1.8

语言:kotlin

系统:macOs Big Sur 11.2 (20D64)

修改的类:

    private fun gotoConfigChangeActivity() {
        //throw IllegalArgumentException("")
        RobustModify.modify()
        RouterXX.startActivity(this, ConfigChangeActivity::class.java)
        //如果不新增 RouterXX.startActivity(this, ConfigChangeActivity::class.java) 方法,直接调用下面注释方法,则可以生成patch.jar
        //startActivity(Intent(this, ConfigChangeActivity::class.java))
    }

新增的类:


@Add
public class RouterXX {

    public constructor()

    companion object {

        fun startActivity(context: Context, cls: Class<*>, bundle: Bundle? = null) {
            val intent = Intent(context, cls)
            bundle?.let {
                intent.putExtras(it)
            }
            context.startActivity(intent)
        }
    }
}

堆栈/日志:

================autoPatch start================ autopatch read all class file cost 0.345 second check all class cost 1.61 second, class count: 5371 new add methods list is

new add classes list is key is com.piaoyou.systrace.utils.RouterXX

patchMethodSignatureSet is printed below key is com.piaoyou.systrace.home.view.MainActivity.gotoConfigChangeActivity()

Warning class name startActivity$default(com.piaoyou.systrace.utils.RouterXX$Companion,android.content.Context,java.lang.Class,android.os.Bundle,int,java.lang.Object) can not find in mapping !! java -jar /Users/zhan/motianlun/project/systrace/app/robust/dx.jar --dex --output=classes.dex meituan.jar errorStream output

Task :app:transformClassesWithAutoPatchTransformForRelease FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings 23 actionable tasks: 21 executed, 2 up-to-date

zhanf commented 3 years ago

已解决!

解决办法:clone robust 项目本地集成 ,替换 dx.jar 为 Android Studio 内的 dx.jar。 问题直接原因:打包的 dx.jar 跟 打差分包的 dx.jar 版本不一致导致。 问题根本原因:Robust 项目下 auto-patch-plugin 插件 dx.jar(resources/libs/dx.jar) ,不可定制。

luobosu commented 3 years ago

已解决!

解决办法:clone robust 项目本地集成 ,替换 dx.jar 为 Android Studio 内的 dx.jar。 问题直接原因:打包的 dx.jar 跟 打差分包的 dx.jar 版本不一致导致。 问题根本原因:Robust 项目下 auto-patch-plugin 插件 dx.jar(resources/libs/dx.jar) ,不可定制。

补充,使用sdk中,buildtools中的最新dx.jar文件进行替代即可。感谢分享