gpt4 book ai didi

java - Android 应用程序因 RuntimeException : Unable to instantiate activity, dident find 类而崩溃

转载 作者:行者123 更新时间:2023-11-29 08:53:13 27 4
gpt4 key购买 nike

我正在创建一个 android 应用程序,每当我尝试运行它时,应用程序立即崩溃,我在 LogCat 中收到以下错误

02-08 23:36:55.846: E/AndroidRuntime(15192): FATAL EXCEPTION: main
02-08 23:36:55.846: E/AndroidRuntime(15192): Process: com.danielscode.cube, PID: 15192
02-08 23:36:55.846: E/AndroidRuntime(15192): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.danielscode.cube/com.danielscode.cube.CUBEMenuActivity}: java.lang.ClassNotFoundException: Didn't find class "com.danielscode.cube.CUBEMenuActivity" on path: DexPathList[[zip file "/data/app/com.danielscode.cube-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.danielscode.cube-2, /vendor/lib, /system/lib]]
02-08 23:36:55.846: E/AndroidRuntime(15192): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
02-08 23:36:55.846: E/AndroidRuntime(15192): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
02-08 23:36:55.846: E/AndroidRuntime(15192): at android.app.ActivityThread.access$800(ActivityThread.java:135)
02-08 23:36:55.846: E/AndroidRuntime(15192): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
02-08 23:36:55.846: E/AndroidRuntime(15192): at android.os.Handler.dispatchMessage(Handler.java:102)
02-08 23:36:55.846: E/AndroidRuntime(15192): at android.os.Looper.loop(Looper.java:136)
02-08 23:36:55.846: E/AndroidRuntime(15192): at android.app.ActivityThread.main(ActivityThread.java:5017)
02-08 23:36:55.846: E/AndroidRuntime(15192): at java.lang.reflect.Method.invokeNative(Native Method)
02-08 23:36:55.846: E/AndroidRuntime(15192): at java.lang.reflect.Method.invoke(Method.java:515)
02-08 23:36:55.846: E/AndroidRuntime(15192): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-08 23:36:55.846: E/AndroidRuntime(15192): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-08 23:36:55.846: E/AndroidRuntime(15192): at dalvik.system.NativeStart.main(Native Method)
02-08 23:36:55.846: E/AndroidRuntime(15192): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.danielscode.cube.CUBEMenuActivity" on path: DexPathList[[zip file "/data/app/com.danielscode.cube-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.danielscode.cube-2, /vendor/lib, /system/lib]]
02-08 23:36:55.846: E/AndroidRuntime(15192): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
02-08 23:36:55.846: E/AndroidRuntime(15192): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
02-08 23:36:55.846: E/AndroidRuntime(15192): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
02-08 23:36:55.846: E/AndroidRuntime(15192): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
02-08 23:36:55.846: E/AndroidRuntime(15192): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
02-08 23:36:55.846: E/AndroidRuntime(15192): ... 11 more

我的第一个想法是我在 manafest 文件中拼写了类名,但我已经双重和三重检查,它们是正确的。以下是我的manafest文件

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.danielscode.cube"
android:versionCode="1"
android:versionName="0.1" >

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />

<application
android:allowBackup="true"
android:icon="@drawable/cubeicon1"
android:label="@string/app_name"
android:theme="@style/AppTheme">

<activity android:name=".CUBEMenuActivity">

<intent-filter>

<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>
</activity>

<activity android:name=".CUBEGameActivity"></activity>

</application>
</manifest>

有没有人遇到过类似的问题?任何解决此问题的帮助将不胜感激。

最佳答案

我认为你的问题是你的类 CubeMenuActivitycom.danielscode.cube。如果您看到您的 list ,那么您已经定义了该包,而不是在您的 java 类中。

从您的 AndroidManifest.xml 中删除包或将您的类移动到符合您的 list 中声明的​​包。

关于java - Android 应用程序因 RuntimeException : Unable to instantiate activity, dident find 类而崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21645754/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com