Meituan-Dianping / Meituan-Dianping/Robust

使用kotlin时。对于kotlin-android-extensions 生成的控件。修复的时候,报错该控件为null。

Open
#436 1 comment 1 reaction 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

异常类型:app运行时异常

手机型号:小米10青春版

手机系统版本:Android 10

Robust版本:0.4.99

Gradle版本:4.0.1

备注:下方报错信息中,“tvHot must not be null”里 tvHot 是通过kotlin-android-extensions映射的控件。热修复后。找不到该控件

系统:Mac
堆栈/日志:
2020-11-13 11:39:56.692 25631-25631/? D/ForceDarkHelper: updateByCheckExcludeList: pkg: com.hans.robusttest activity: com.hans.robusttest.MainHotpatchActivity@f573c76
2020-11-13 11:39:56.694 25631-25631/? W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at com.meituan.robust.utils.EnhancedRobustUtils.invokeReflectMethod(EnhancedRobustUtils.java:2)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at com.hans.robusttest.patch.MainHotpatchActivityPatch.onCreate(MainHotpatchActivityPatch.java:16)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at com.hans.robusttest.patch.MainHotpatchActivityPatchControl.accessDispatch(Unknown Source:75)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at com.meituan.robust.PatchProxy.accessDispatch(PatchProxy.java:9)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at com.meituan.robust.PatchProxy.proxy(PatchProxy.java:4)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at com.hans.robusttest.MainHotpatchActivity.onCreate(Unknown Source:20)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.app.Activity.performCreate(Activity.java:7893)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.app.Activity.performCreate(Activity.java:7880)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3286)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3460)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:107)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.os.Looper.loop(Looper.java:224)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7584)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
2020-11-13 11:39:56.695 25631-25631/? W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
2020-11-13 11:39:56.697 25631-25631/? W/System.err: java.lang.reflect.InvocationTargetException
2020-11-13 11:39:56.699 25631-25631/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2020-11-13 11:39:56.699 25631-25631/? W/System.err: at com.meituan.robust.utils.EnhancedRobustUtils.invokeReflectStaticMethod(EnhancedRobustUtils.java:3)
2020-11-13 11:39:56.699 25631-25631/? W/System.err: at com.hans.robusttest.patch.MainHotpatchActivityPatch.onCreate(MainHotpatchActivityPatch.java:16)
2020-11-13 11:39:56.699 25631-25631/? W/System.err: at com.hans.robusttest.patch.MainHotpatchActivityPatchControl.accessDispatch(Unknown Source:75)
2020-11-13 11:39:56.699 25631-25631/? W/System.err: at com.meituan.robust.PatchProxy.accessDispatch(PatchProxy.java:9)
2020-11-13 11:39:56.699 25631-25631/? W/System.err: at com.meituan.robust.PatchProxy.proxy(PatchProxy.java:4)
2020-11-13 11:39:56.699 25631-25631/? W/System.err: at com.hans.robusttest.MainHotpatchActivity.onCreate(Unknown Source:20)
2020-11-13 11:39:56.699 25631-25631/? W/System.err: at android.app.Activity.performCreate(Activity.java:7893)
2020-11-13 11:39:56.699 25631-25631/? W/System.err: at android.app.Activity.performCreate(Activity.java:7880)
2020-11-13 11:39:56.699 25631-25631/? W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
2020-11-13 11:39:56.699 25631-25631/? W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3286)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3460)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:107)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.os.Looper.loop(Looper.java:224)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7584)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: Caused by: java.lang.IllegalStateException: tvHot must not be null
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at java.lang.reflect.Constructor.newInstance0(Native Method)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.meituan.robust.utils.EnhancedRobustUtils.invokeReflectConstruct(EnhancedRobustUtils.java:4)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.hans.robusttest.patch.IntrinsicsInLinePatch.checkExpressionValueIsNotNull(IntrinsicsInLinePatch.java:87)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: ... 22 more
2020-11-13 11:39:56.700 25631-25631/? W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.meituan.robust.utils.EnhancedRobustUtils.getDeclaredMethod(EnhancedRobustUtils.java:3)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.meituan.robust.utils.EnhancedRobustUtils.invokeReflectMethod(EnhancedRobustUtils.java:1)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.hans.robusttest.patch.MainHotpatchActivityPatch.onCreate(MainHotpatchActivityPatch.java:16)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.hans.robusttest.patch.MainHotpatchActivityPatchControl.accessDispatch(Unknown Source:75)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.meituan.robust.PatchProxy.accessDispatch(PatchProxy.java:9)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.meituan.robust.PatchProxy.proxy(PatchProxy.java:4)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.hans.robusttest.MainHotpatchActivity.onCreate(Unknown Source:20)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.Activity.performCreate(Activity.java:7893)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.Activity.performCreate(Activity.java:7880)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3286)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3460)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:107)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.os.Looper.loop(Looper.java:224)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7584)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
2020-11-13 11:39:56.700 25631-25631/? W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
2020-11-13 11:39:56.706 11872-11872/? D/RecentsImpl: mActivityStateObserver com.hans.robusttest.MainHotpatchActivity

类文件:MainHotpatchActivity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.meituan.robust.patch.annotaion.Add
import com.meituan.robust.patch.annotaion.Modify
import kotlinx.android.synthetic.main.activity_main_hotpatch.*

class MainHotpatchActivity : AppCompatActivity() {

@Modify
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main_hotpatch)
    tvHot.text = getFix()
}

fun getBug(): String {
    return "还没修复好呢!!#!@#!@#!@#!修复了了了了了"
}

@Add
fun getFix(): String {
    return "fix 修复"
}

}

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

Start by reproducing the issue with MainHotpatchActivity and the generated MainHotpatchActivityPatch, using the provided stack trace and Robust 0.4.99 setup as references. Inspect the reflective calls through EnhancedRobustUtils and the Kotlin synthetic view access. Done means the hotfix can access tvHot after setContentView without the reported null-related exceptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
devtools, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.