2013-06-26 57 views
0

我使用Cocos2dx庫設置Eclipse IDE。我試圖在cocos2dx庫中設置並運行helloworld項目,但是在helloworld.apk成功上傳到模擬器後,我在LogCat中遇到此錯誤。.apk上傳成功,但在ClassNotFoundException中啓動意圖結果com.game.demo.helloworld

我在SDK 17 Eclipse構建:v22.0.1-685705

我已經通過計算器上幾乎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

郵政helloworld.java(一個開始'package')在helloworld.java –

+0

第一行是第一行:包com.game.demo.helloworld;這與AndroidManifest.xml中的android:name標籤值相匹配。但我認爲我只是錯誤地引用了軟件包?讓我更新該項目的屏幕截圖...也許這將有助於... – user2518312

+0

我沒有足夠的分數來添加屏幕截圖。 – user2518312

回答

0

我剛做了一個類似的錯誤,昨天還沒有與上所提供的所有答案的成功。 我終於找到了:

我在代碼中的任何地方都使用了「ViewPager」。

但是,在使用過的.xml文件中,我偶然輸入了「viewPager」 - 當然那個找不到。

另外,正如我今天發現的那樣,如果有的話,請仔細檢查您在.xml中使用的對象的包名。

0

你用apk輸出了cocos2dx jar嗎?如果不是這樣,它會編譯,但會崩潰。

1

您的清單包被聲明爲com.game.demo,但您的文件位於com.game.demo.helloworld

嘗試:

<activity android:name="com.game.demo.helloworld.helloworld" 
相關問題