ShareEntryActivity java.lang.ClassNotFoundException | Android类找不到问题

错误堆栈:

    Process: com.mci.smagazine, PID: 23265
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mci.smagazine/com.mci.smagazine.apshare.ShareEntryActivity}: java.lang.ClassNotFoundException: com.mci.smagazine.apshare.ShareEntryActivity in loader com.zhangyue.iReader.plugin.d[DexPathList[[zip file "/data/app/com.mci.smagazine-oVAsxbpVt3Q0D6kLqRDP-g==/base.apk"],nativeLibraryDirectories=[/system/lib, /vendor/lib]]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2911)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3101)
        at android.app.ActivityThread.-wrap12(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1741)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:187)
        at android.app.ActivityThread.main(ActivityThread.java:7114)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:814)
     Caused by: java.lang.ClassNotFoundException: com.mci.smagazine.apshare.ShareEntryActivity in loader com.zhangyue.iReader.plugin.d[DexPathList[[zip file "/data/app/com.mci.smagazine-oVAsxbpVt3Q0D6kLqRDP-g==/base.apk"],nativeLibraryDirectories=[/system/lib, /vendor/lib]]]
        at com.zhangyue.iReader.plugin.d.loadClass(SourceFile:90)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1195)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3101) 
        at android.app.ActivityThread.-wrap12(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1741) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:187) 
        at android.app.ActivityThread.main(ActivityThread.java:7114) 

我的清单里面的声明:

        
        

别人反馈了一个崩溃,log 发给我了。说找不到ShareEntryActivity。我搜了以下工程,确实没有这个类。这个应该是支付宝分享回调的类,我去找测试,测试找了下应该是没有分享的入口。

我突然想到,支付宝分享应该是去掉了的。怎么还会启动呢?不可能。

我全局搜索了一下ShareEntryActivity,我擦,清单里面竟然还有这个声明。

立马就想到,如果外部启动你这个ShareEntryActivity ,你肯定类找不到崩溃。

于是自己用adb 模拟一下:

adb shell
am start-activity com.mci.smagazine/com.mci.smagazine.apshare.ShareEntryActivity
或者am start com.mci.smagazine/com.mci.smagazine.apshare.ShareEntryActivity(有的adb 工具不识别start-activity)
下面这行是让掌阅app 崩溃的
am start-activity com.chaozh.iReaderFree/com.chaozh.iReaderFree.apshare.ShareEntryActivity

总结:

1.清单里面不用的activity 声明,一定要去掉。否则别人随便攻击一下,你就找不到类崩溃了。而且你还自以为是的说,我程序中本来就没有这个类。那没有这个类,你干嘛声明呢?
2.有时候,类找不到,不一定清单里面没有声明。有时候搜索要全局搜索一下。

转载于:https://www.cnblogs.com/caoxinyu/p/10568459.html

你可能感兴趣的:(ShareEntryActivity java.lang.ClassNotFoundException | Android类找不到问题)