Android应用程序启动时发生AndroidRuntime : ClassNotFoundException for Activity class的解决方法

本文针对Android应用启动时报出特定异常导致无法启动的问题提供了解决方案,包括检查Activity名称、路径配置、外部包引入及清理项目等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在android应用程序启动时抛出下面异常导致启动失败:
07-09 17:12:35.709: ERROR/AndroidRuntime(3866): Uncaught handler: thread main exiting due to uncaught exception

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.anselm.eickhoff.rhythm/org.anselm.eickhoff.rhythm.RhythmGameActivity}: java.lang.ClassNotFoundException: org.anselm.eickhoff.rhythm.RhythmGameActivity in loader dalvik.system.PathClassLoader@4001e740

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2497)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at android.app.ActivityThread.access$2200(ActivityThread.java:126)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at android.os.Handler.dispatchMessage(Handler.java:99)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at android.os.Looper.loop(Looper.java:123)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at android.app.ActivityThread.main(ActivityThread.java:4595)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at java.lang.reflect.Method.invokeNative(Native Method)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at java.lang.reflect.Method.invoke(Method.java:521)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at dalvik.system.NativeStart.main(Native Method)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): Caused by: java.lang.ClassNotFoundException: org.anselm.eickhoff.rhythm.RhythmGameActivity in loader dalvik.system.PathClassLoader@4001e740

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2489)

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): ... 11 more


个人按下面顺序排查:

1.

在Manifest.xml中查看Activity的名字是否书写正确。

2.

在Manifest.xml确认Activity标签中的android:name属性的格式,例如我的activity的名字是helloworld,确认android:name=”.helloworld”(其中的点很重要)。

3.

如果有添加外部包的情况下,在工程根目录下建libs目录,然后将需要导入的外部包放入此目录内再add jars。

4.

如果上面都确保OK的情况下仍发生问题的话,clean工程->关闭eclipse->在命令行中重启adb(adb kill-server adbstart-server)->打开eclipse->编译启动。

 

上面4步基本能解决问题。

发生crash的原因,通俗易懂的方式 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: Process: com.smile.gifmaker, PID: 18519 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.smile.gifmaker/com.yxcorp.gifshow.tube.TubeRouterActivity}: java.lang.ClassNotFoundException: Didn't find class "com.yxcorp.gifshow.tube.TubeRouterActivity" on path: DexPathList[[zip file "/my_preload/del-app/kuaishou/com.smile.gifmaker.apk"],nativeLibraryDirectories=[/data/preapps-lib/kuaishou/lib/arm64, /my_preload/del-app/kuaishou/com.smile.gifmaker.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]] 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4255) 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4569) 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:126) 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:179) 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:114) 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:86) 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2902) 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107) 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:282) 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: at android.os.Looper.loop(Looper.java:387) 03-27 07:28:15.239382 18519 18519 E AndroidRuntime: a
最新发布
04-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值