Skip to content

热修复后,调用Application类中的public方法会crash #1777

Description

@wbq888
class Application : TinkerApplication("com.xxx.xxx.ApplicationLike"){
    fun printLog() {
        Log.d("Application", "Application")
    }
}

外部调用Application 方法:

(application as Application).printLog()

全量的两个apk包都不会有问题,但是补丁包加载后,这里会crash
FATAL EXCEPTION: main Process: com.xxx.sample.hotfix, PID: 27752
java.lang.ClassCastException: com.xxx.sample.hotfix.app.Application cannot be cast to com.xxx.sample.hotfix.app.Application

按照Tinker 自定义扩展,Application逻辑如果移到代理类是为了避免补丁包是无法对Application和其引用类修改。所以想了解:

  1. 如果我不想热更新Application,怎么可以不crash
  2. 这个为什么会不能将自己类转换为自己(怀疑和classloder有关)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions