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

启动androidx崩溃问题 #92

Open
limaofang opened this issue Oct 12, 2023 · 5 comments
Open

启动androidx崩溃问题 #92

limaofang opened this issue Oct 12, 2023 · 5 comments

Comments

@limaofang
Copy link

                                            Process: com.example.shell, PID: 21636
                                                                                                java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: No implementation found for void androidx.lifecycle.DefaultLifecycleObserver.onCreate(androidx.lifecycle.LifecycleOwner) (tried Java_androidx_lifecycle_DefaultLifecycleObserver_onCreate and Java_androidx_lifecycle_DefaultLifecycleObserver_onCreate__Landroidx_lifecycle_LifecycleOwner_2)
                                                                                                	at android.app.ActivityThread.installProvider(ActivityThread.java:7413)
                                                                                                	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6914)
                                                                                                	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6809)
                                                                                                	at android.app.ActivityThread.access$1700(ActivityThread.java:240)
                                                                                                	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2068)
                                                                                                	at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                                                	at android.os.Looper.loop(Looper.java:238)
                                                                                                	at android.app.ActivityThread.main(ActivityThread.java:7798)
                                                                                                	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:512)
                                                                                                	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)
                                                                                                Caused by: androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: No implementation found for void androidx.lifecycle.DefaultLifecycleObserver.onCreate(androidx.lifecycle.LifecycleOwner) (tried Java_androidx_lifecycle_DefaultLifecycleObserver_onCreate and Java_androidx_lifecycle_DefaultLifecycleObserver_onCreate__Landroidx_lifecycle_LifecycleOwner_2)
                                                                                                	at androidx.startup.AppInitializer.doInitialize(Native Method)
                                                                                                	at androidx.startup.AppInitializer.discoverAndInitialize(Native Method)
                                                                                                	at androidx.startup.AppInitializer.discoverAndInitialize(Native Method)
                                                                                                	at androidx.startup.InitializationProvider.onCreate(Native Method)
                                                                                                	at android.content.ContentProvider.attachInfo(ContentProvider.java:2102)
                                                                                                	at android.content.ContentProvider.attachInfo(ContentProvider.java:2076)
                                                                                                	at android.app.ActivityThread.installProvider(ActivityThread.java:7408)
                                                                                                	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6914) 
                                                                                                	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6809) 
                                                                                                	at android.app.ActivityThread.access$1700(ActivityThread.java:240) 
                                                                                                	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2068) 
                                                                                                	at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                                                	at android.os.Looper.loop(Looper.java:238) 
                                                                                                	at android.app.ActivityThread.main(ActivityThread.java:7798) 
                                                                                                	at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:512) 
                                                                                                	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995) 
                                                                                                Caused by: java.lang.UnsatisfiedLinkError: No implementation found for void androidx.lifecycle.DefaultLifecycleObserver.onCreate(androidx.lifecycle.LifecycleOwner) (tried Java_androidx_lifecycle_DefaultLifecycleObserver_onCreate and Java_androidx_lifecycle_DefaultLifecycleObserver_onCreate__Landroidx_lifecycle_LifecycleOwner_2)
                                                                                                	at androidx.lifecycle.DefaultLifecycleObserver.onCreate(Native Method)
                                                                                                	at androidx.lifecycle.DefaultLifecycleObserverAdapter.onStateChanged(Native Method)
                                                                                                	at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(Native Method)
                                                                                                	at androidx.lifecycle.LifecycleRegistry.addObserver(Native Method)
                                                                                                	at androidx.emoji2.text.EmojiCompatInitializer.delayUntilFirstResume(Native Method)
                                                                                                	at androidx.emoji2.text.EmojiCompatInitializer.create(Native Method)
                                                                                                	at androidx.emoji2.text.EmojiCompatInitializer.create(Unknown Source:73)
                                                                                                	at androidx.startup.AppInitializer.doInitialize(Native Method) 
                                                                                                	at androidx.startup.AppInitializer.discoverAndInitialize(Native Method) 
                                                                                                	at androidx.startup.AppInitializer.discoverAndInitialize(Native Method) 
                                                                                                	at androidx.startup.InitializationProvider.onCreate(Native Method) 
                                                                                                	at android.content.ContentProvider.attachInfo(ContentProvider.java:2102) 
                                                                                                	at android.content.ContentProvider.attachInfo(ContentProvider.java:2076) 
                                                                                                	at android.app.ActivityThread.installProvider(ActivityThread.java:7408) 
                                                                                                	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6914) 
                                                                                                	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6809) 
                                                                                                	at android.app.ActivityThread.access$1700(ActivityThread.java:240) 
                                                                                                	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2068) 
                                                                                                	at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                                                	at android.os.Looper.loop(Looper.java:238) 
                                                                                                	at android.app.ActivityThread.main(ActivityThread.java:7798) 
                                                                                                	at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:512) 
                                                                                                	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995) 

该如何处理?

@maoabc
Copy link
Owner

maoabc commented Oct 12, 2023

找之前的issue有相关讨论, 要加固androidx相关,自己改so加载位置到自定义application里。顺便说一句加固开源库没任何意义,还能让人简单找到opcode映射表。这种跟那些隐藏dex的加固有很大的不同,弄清楚基本原理再使用。

@limaofang
Copy link
Author

找之前的issue有相关讨论, 要加固androidx相关,自己改so加载位置到自定义application里。顺便说一句加固开源库没任何意义,还能让人简单找到opcode映射表。这种跟那些隐藏dex的加固有很大的不同,弄清楚基本原理再使用。

有参考的代码可以看看吗?

@maoabc
Copy link
Owner

maoabc commented Oct 13, 2023

找之前的issue有相关讨论, 要加固androidx相关,自己改so加载位置到自定义application里。顺便说一句加固开源库没任何意义,还能让人简单找到opcode映射表。这种跟那些隐藏dex的加固有很大的不同,弄清楚基本原理再使用。

有参考的代码可以看看吗?

可以看以前代码,最初就是在自定义application里注入的静态初始化方法里System.loadLibrary("libnmmp.so")。后面更新才在NativeUtils里加载so,目前只是推测原因(两个类互相引用,类加载时导致静态初始化方法还没执行就提前调用本地方法,然后报错找到不到native方法)。简单解决就是忽略一些类,打断这种循环引用,或者前面提到的自定义appliction里加载so

@mythoi
Copy link

mythoi commented Sep 29, 2024

找之前的issue有相关讨论, 要加固androidx相关,自己改so加载位置到自定义application里。顺便说一句加固开源库没任何意义,还能让人简单找到opcode映射表。这种跟那些隐藏dex的加固有很大的不同,弄清楚基本原理再使用。

有参考的代码可以看看吗?

可以看以前代码,最初就是在自定义application里注入的静态初始化方法里System.loadLibrary("libnmmp.so")。后面更新才在NativeUtils里加载so,目前只是推测原因(两个类互相引用,类加载时导致静态初始化方法还没执行就提前调用本地方法,然后报错找到不到native方法)。简单解决就是忽略一些类,打断这种循环引用,或者前面提到的自定义appliction里加载so

大佬问下,出于什么原因改到NativeUtils里加载so呢?

@maoabc
Copy link
Owner

maoabc commented Sep 29, 2024

找之前的issue有相关讨论, 要加固androidx相关,自己改so加载位置到自定义application里。顺便说一句加固开源库没任何意义,还能让人简单找到opcode映射表。这种跟那些隐藏dex的加固有很大的不同,弄清楚基本原理再使用。

有参考的代码可以看看吗?

可以看以前代码,最初就是在自定义application里注入的静态初始化方法里System.loadLibrary("libnmmp.so")。后面更新才在NativeUtils里加载so,目前只是推测原因(两个类互相引用,类加载时导致静态初始化方法还没执行就提前调用本地方法,然后报错找到不到native方法)。简单解决就是忽略一些类,打断这种循环引用,或者前面提到的自定义appliction里加载so

大佬问下,出于什么原因改到NativeUtils里加载so呢?

为了让代码更简洁些,不用再额外处理自定义application。后面发现处理androidx就会出现native方法在System.loadLibrary()执行前调用的bug,按正常逻辑其他加固类会先调用NativeUtils里的initClass方法,这时NativeUtils的static{}方法会最先执行。不过一般情况根本不会处理androidx,遇到这类问题可以通过限制加固范围解决,所以就没必要回退到在自定义application里加载so

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

3 participants