Meituan-Dianping / Meituan-Dianping/Robust

在修改的方法中引用已知类,出现ClassNotFoundException

Open
#413 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
4.5k
Forks
806
PR merge metrics
No merged PRs in 30d

Description

在修改的方法中引用已知类,出现ClassNotFoundException,示例代码如下:
修复前:
private void robustAddMethod() {
Log.e("mytag", "robustAddMethod");
}
修复后:
@Modify
private void robustAddMethod() {
Log.e("mytag", "robustAddMethod");
Glide.with(this);
showToast("新增showToast方法: " + Process.myPid() + " " + Glide.with(this).toString());
}

问题的关键在于,引用的类并不是新增类,但是这个类如果是我们自己写的,则可以通过把类标记为新增类来解决,但是引用的是第三方的类就没有办法了。

异常类型:app运行时异常

手机型号:所有

手机系统版本:Android P
Robust版本:如:0.4.99

Gradle版本:3.5.3

系统:如:Windows

堆栈/日志:

2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/bumptech/glide/Glide;
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at com.cy.hotfix.test.RobustTestActivityPatch.robustModifyMethod(RobustTestActivityPatch.java:63)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at com.cy.hotfix.test.RobustTestActivityPatch.RobustPublicrobustModifyMethod(Unknown Source:0)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at com.cy.hotfix.test.RobustTestActivityPatchControl.accessDispatch(Unknown Source:91)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at com.meituan.robust.PatchProxy.accessDispatch(:94)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at com.meituan.robust.PatchProxy.proxy(:44)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at com.cy.hotfix.test.activity.RobustTestActivity.s(Unknown Source:13)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at com.cy.hotfix.test.activity.RobustTestActivity.onClick(:38)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at android.view.View.performClick(View.java:7247)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at android.view.View.performClickInternal(View.java:7224)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at android.view.View.access$3500(View.java:819)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at android.view.View$PerformClick.run(View.java:27551)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at android.os.Handler.handleCallback(Handler.java:914)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at android.os.Handler.dispatchMessage(Handler.java:100)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at android.os.Looper.loop(Looper.java:225)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7594)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
2020-07-01 12:07:43.842 32384-32384/com.cy.hotfix.test.robust W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
2020-07-01 12:07:43.843 32384-32384/com.cy.hotfix.test.robust W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.bumptech.glide.Glide" on path: DexPathList[[zip file "/data/user/0/com.cy.hotfix.test.robust/cache/patches/patch_temp.jar"],nativeLibraryDirectories=[/system/lib64, /system/product/lib64]]
2020-07-01 12:07:43.843 32384-32384/com.cy.hotfix.test.robust W/System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:230)
2020-07-01 12:07:43.843 32384-32384/com.cy.hotfix.test.robust W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
2020-07-01 12:07:43.843 32384-32384/com.cy.hotfix.test.robust W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
2020-07-01 12:07:43.843 32384-32384/com.cy.hotfix.test.robust W/System.err: ... 18 more

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Android P failure using the shown @Modify method and its Glide reference. Start by examining how patch_temp.jar is loaded and how the class loader resolves classes, using the provided NoClassDefFoundError stack trace as the entry point. Done means a modified method can reference the existing third-party class without the reported runtime exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.