Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android13-debug环境补丁加载正常,release加载成功,但重启app会连续崩溃3次并自动清理补丁 #1734

Open
yanjunhui2014 opened this issue Nov 20, 2023 · 4 comments

Comments

@yanjunhui2014
Copy link

yanjunhui2014 commented Nov 20, 2023

异常类型:应用启动奔溃(debug包正常,release则出现奔溃),奔溃3次后补丁被清理

手机型号:红米k40s、华为nova11

手机系统版本:Android13、鸿蒙OS4.0.0

tinker版本:1.9.14.26

gradle版本:4.1.3

compileSdkVersion - 32
targetSdkVersion - 32

是否使用热更新SDK: 使用,接入方式借鉴于tinker-sample-android

系统:Mac

gradle.properties配置如图(我以前android.enableR8=false没有注释之前,补丁是正常的)

image

堆栈/日志:

java.lang.NoSuchMethodError: No static method e()Lcom/facebook/AccessToken; in class Lcom/facebook/AccessToken; or its super classes (declaration of 'com.facebook.AccessToken' appears in /data/user/0/com.ishowedu.aitalk/tinker/patch-8f378bc4/dex/tinker_classN.apk!classes2.dex)
No static method e()Lcom/facebook/AccessToken; in class Lcom/facebook/AccessToken; or its super classes (declaration of 'com.facebook.AccessToken' appears in /data/user/0/com.ishowedu.aitalk/tinker/patch-8f378bc4/dex/tinker_classN.apk!classes2.dex)
java.lang.NoSuchMethodError: No static method e()Lcom/facebook/AccessToken; in class Lcom/facebook/AccessToken; or its super classes (declaration of 'com.facebook.AccessToken' appears in /data/user/0/com.ishowedu.aitalk/tinker/patch-8f378bc4/dex/tinker_classN.apk!classes2.dex)
    at com.facebook.FacebookSdk.g(FacebookSdk.kt:1)
    at com.facebook.GraphRequest.g(GraphRequest.kt:6)
    at com.facebook.GraphRequest$Companion.q(GraphRequest.kt:15)
    at com.facebook.GraphRequest$Companion.c(GraphRequest.kt:2)
    at com.facebook.GraphRequest.c(GraphRequest.kt:6)
    at com.facebook.internal.FetchedAppGateKeepersManager.a(FetchedAppGateKeepersManager.kt:9)
    at b.b.u.f.run(lambda:2)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:930)
Back traces ends.

而后,我把com.facebook.android移除,相同类型的异常还存在

java.lang.NoSuchMethodError: No virtual method j()Landroid/view/View; in class Lcom/zhl/commonadapter/BaseViewHolder; or its super classes (declaration of 'com.zhl.commonadapter.BaseViewHolder' appears in /data/user/0/com.ishowedu.aitalk/tinker/patch-0bc5821f/dex/tinker_classN.apk!classes2.dex)
No virtual method j()Landroid/view/View; in class Lcom/zhl/commonadapter/BaseViewHolder; or its super classes (declaration of 'com.zhl.commonadapter.BaseViewHolder' appears in /data/user/0/com.ishowedu.aitalk/tinker/patch-0bc5821f/dex/tinker_classN.apk!classes2.dex)
java.lang.NoSuchMethodError: No virtual method j()Landroid/view/View; in class Lcom/zhl/commonadapter/BaseViewHolder; or its super classes (declaration of 'com.zhl.commonadapter.BaseViewHolder' appears in /data/user/0/com.ishowedu.aitalk/tinker/patch-0bc5821f/dex/tinker_classN.apk!classes2.dex)
	at com.zhl.commonadapter.CommonRecyclerAdapter.i(CommonRecyclerAdapter.java:9)
	at androidx.recyclerview.widget.RecyclerView$Recycler.k(RecyclerView.java:122)
	at androidx.recyclerview.widget.RecyclerView$Recycler.e(RecyclerView.java:1)
	at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.c(LinearLayoutManager.java:8)
	at androidx.recyclerview.widget.LinearLayoutManager.y1(LinearLayoutManager.java:1)
	at androidx.recyclerview.widget.LinearLayoutManager.l1(LinearLayoutManager.java:12)
	at androidx.recyclerview.widget.LinearLayoutManager.z0(LinearLayoutManager.java:119)
	at androidx.recyclerview.widget.RecyclerView.s(RecyclerView.java:14)
	at androidx.recyclerview.widget.RecyclerView.q(RecyclerView.java:15)
	at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:3)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at androidx.swiperefreshlayout.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:11)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1103)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:12)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:359)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:295)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at androidx.recyclerview.widget.RecyclerView$LayoutManager.e0(RecyclerView.java:3)
	at androidx.recyclerview.widget.LinearLayoutManager.y1(LinearLayoutManager.java:47)
	at androidx.recyclerview.widget.LinearLayoutManager.l1(LinearLayoutManager.java:12)
	at androidx.recyclerview.widget.LinearLayoutManager.z0(LinearLayoutManager.java:119)
	at androidx.recyclerview.widget.RecyclerView.s(RecyclerView.java:14)
	at androidx.recyclerview.widget.RecyclerView.q(RecyclerView.java:15)
	at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:3)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:8)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:12)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1103)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:359)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:295)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1870)
	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1714)
	at android.widget.LinearLayout.onLayout(LinearLayout.java:1623)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:359)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:295)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1870)
	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1714)
	at android.widget.LinearLayout.onLayout(LinearLayout.java:1623)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:359)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:295)
	at com.android.internal.policy.DecorView.onLayout(DecorView.java:1319)
	at android.view.View.layout(View.java:24285)
	at android.view.ViewGroup.layout(ViewGroup.java:6758)
	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:5200)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4528)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:3132)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:11095)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1592)
	at android.view.Choreographer.doCallbacks(Choreographer.java:1256)
	at android.view.Choreographer.doFrame(Choreographer.java:1125)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1542)
	at android.os.Handler.handleCallback(Handler.java:966)
	at android.os.Handler.dispatchMessage(Handler.java:110)
	at android.os.Looper.loopOnce(Looper.java:205)
	at android.os.Looper.loop(Looper.java:293)
	at android.app.ActivityThread.loopProcess(ActivityThread.java:9934)
	at android.app.ActivityThread.main(ActivityThread.java:9923)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:586)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1240)

提问题时若使用不能用/没效果/有问题/报错此类模糊表达,但又没给出任何代码截图报错的,将绝对不会有任何反馈。这种issue也是一律直接关闭的,大家可以参阅提问的智慧

Tinker是一个开源项目,希望大家遇到问题时要学会先思考,看看sample与Tinker的源码,更鼓励大家给我们提pr.

@yanjunhui2014 yanjunhui2014 changed the title Android12-debug环境补丁加载正常,release加载成功,但重启app会连续崩溃3次并自动清理补丁 Android13-debug环境补丁加载正常,release加载成功,但重启app会连续崩溃3次并自动清理补丁 Nov 22, 2023
@yanjunhui2014
Copy link
Author

确定了,系混淆开关导致。目前release混淆关闭,补丁就能正常加载。ext.tinkerApplyMappingPath 确认配置无误。请问这种情况和android.enableR8的修改有关吗?

@yanjunhui2014
Copy link
Author

解决了,我解决的办法是在proguard-rules.pro中加入 -dontoptimize
(根目录gradle.properties中android.enableR8被注释之后,需要添加-dontoptimize,否则开启混淆后补丁即使加载成功,app也会奔溃)

@yanjunhui2014
Copy link
Author

yanjunhui2014 commented Dec 25, 2023

目前tinker补丁已经可以正常使用了,总结一下吧。
如果希望tinker可以正常使用,且修复率保持在99%+的水准,需要保证android.enableR8=false

projectDir/gradle.properties

android.enableR8.libraries=false
android.enableR8=false

如果你的工程在开启混淆后编译时提示你

Please correct the above warnings first.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:minifyDebugWithProguard'.
......
Caused by: org.gradle.api.UncheckedIOException: java.io.IOException: Please correct the above warnings
......
Caused by: java.io.IOException: Please correct the above warnings first.
	at proguard.InputReader.execute(InputReader.java:149)
	at proguard.ProGuard.readInput(ProGuard.java:255)
	at proguard.ProGuard.execute(ProGuard.java:96)
......

那么你只需要在你的混淆文件projectDir/proguard-rules.pro中加入

-dontoptimize
-ignorewarnings

然后就可以通过编译了,而且打出来的补丁修复率极高。

当然,如果你不得不注释

android.enableR8.libraries=false
android.enableR8=false

那么混淆文件中配置

-dontoptimize

也可以保证你补丁正常生成,只不过补丁的成功率智能维持在95%左右。

PS
-dontoptimize
作用:忽略字节码优化

@KevonGeng
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants