我使用Cocos2dx库设置了Eclipse IDE。我正在尝试在cocos2dx库中设置并运行helloworld项目,但是在helloworld.apk成功上传到模拟器后,我在LogCat中遇到此错误。
我在SDK 17上 Eclipse Build:v22.0.1-685705
我已经在stackoverflow上查看了近4-5个类似的帖子但是已经尝试了所有内容而不确定如何解决这个问题。
这是LogCat条目:
06-26 06:30:27.411: E/AndroidRuntime(781): FATAL EXCEPTION: main
06-26 06:30:27.411: E/AndroidRuntime(781): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.game.demo/com.game.demo.helloworld}: java.lang.ClassNotFoundException: Didn't find class "com.game.demo.helloworld" on path: /data/app/com.game.demo-2.apk
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.os.Looper.loop(Looper.java:137)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-26 06:30:27.411: E/AndroidRuntime(781): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 06:30:27.411: E/AndroidRuntime(781): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 06:30:27.411: E/AndroidRuntime(781): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-26 06:30:27.411: E/AndroidRuntime(781): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-26 06:30:27.411: E/AndroidRuntime(781): at dalvik.system.NativeStart.main(Native Method)
06-26 06:30:27.411: E/AndroidRuntime(781): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.game.demo.helloworld" on path: /data/app/com.game.demo-2.apk
06-26 06:30:27.411: E/AndroidRuntime(781): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
06-26 06:30:27.411: E/AndroidRuntime(781): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-26 06:30:27.411: E/AndroidRuntime(781): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
06-26 06:30:27.411: E/AndroidRuntime(781): ... 11 more
06-26 06:30:27.411: E/AndroidRuntime(781): FATAL EXCEPTION: main
06-26 06:30:27.411: E/AndroidRuntime(781): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.game.demo/com.game.demo.helloworld}: java.lang.ClassNotFoundException: Didn't find class "com.game.demo.helloworld" on path: /data/app/com.game.demo-2.apk
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.os.Looper.loop(Looper.java:137)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-26 06:30:27.411: E/AndroidRuntime(781): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 06:30:27.411: E/AndroidRuntime(781): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 06:30:27.411: E/AndroidRuntime(781): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-26 06:30:27.411: E/AndroidRuntime(781): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-26 06:30:27.411: E/AndroidRuntime(781): at dalvik.system.NativeStart.main(Native Method)
06-26 06:30:27.411: E/AndroidRuntime(781): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.game.demo.helloworld" on path: /data/app/com.game.demo-2.apk
06-26 06:30:27.411: E/AndroidRuntime(781): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
06-26 06:30:27.411: E/AndroidRuntime(781): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-26 06:30:27.411: E/AndroidRuntime(781): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
06-26 06:30:27.411: E/AndroidRuntime(781): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
06-26 06:30:27.411: E/AndroidRuntime(781): ... 11 more
这是我的AndroidManifest.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.game.demo"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8"/>
<uses-feature android:glEsVersion="0x00020000" />
<application android:label="@string/app_name"
android:icon="@drawable/icon">
<activity android:name=".helloworld"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<supports-screens android:largeScreens="true"
android:smallScreens="true"
android:anyDensity="true"
android:normalScreens="true"/>
</manifest>
答案 0 :(得分:1)
您的清单包被声明为com.game.demo
,但您的文件位于com.game.demo.helloworld
。
尝试:
<activity android:name="com.game.demo.helloworld.helloworld"
答案 1 :(得分:0)
我昨天刚刚遇到类似的错误,也没有成功提供SO上提供的所有答案。 我终于找到了什么:
我在代码中的任何地方都使用了“ViewPager”。
但是在使用的.xml文件中,我意外地输入了“viewPager” - 当然无法找到。
此外,正如我今天发现的那样 - 请仔细检查您在.xml中使用的对象的包名称(如果有的话)。
答案 2 :(得分:0)
您是否使用apk导出cocos2dx jar?如果不是这样的话,它会编译,但崩溃。