Java – andengine – cannot instantiate activity

I'm a novice in Android development. I have a problem using andengine I tried to run an empty application, but got a runtime error as follows:

04-01 21:56:16.326: W/dalvikvm(280): Unable to resolve superclass of Lcom/MyApps/TestApp/TestAppActivity; (31)
04-01 21:56:16.326: W/dalvikvm(280): Link of class 'Lcom/MyApps/TestApp/TestAppActivity;' Failed
04-01 21:56:16.336: D/AndroidRuntime(280): Shutting down VM
04-01 21:56:16.336: W/dalvikvm(280): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-01 21:56:16.376: E/AndroidRuntime(280): FATAL EXCEPTION: main
04-01 21:56:16.376: E/AndroidRuntime(280): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.MyApps.TestApp/com.MyApps.TestApp.TestAppActivity}: java.lang.ClassNotFoundException: com.MyApps.TestApp.TestAppActivity in loader dalvik.system.PathClassLoader[/data/app/com.MyApps.TestApp-1.apk]
04-01 21:56:16.376: E/AndroidRuntime(280):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
04-01 21:56:16.376: E/AndroidRuntime(280):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-01 21:56:16.376: E/AndroidRuntime(280):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-01 21:56:16.376: E/AndroidRuntime(280):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-01 21:56:16.376: E/AndroidRuntime(280):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 21:56:16.376: E/AndroidRuntime(280):  at android.os.Looper.loop(Looper.java:123)
04-01 21:56:16.376: E/AndroidRuntime(280):  at android.app.ActivityThread.main(ActivityThread.java:4627)
04-01 21:56:16.376: E/AndroidRuntime(280):  at java.lang.reflect.Method.invokeNative(Native Method)
04-01 21:56:16.376: E/AndroidRuntime(280):  at java.lang.reflect.Method.invoke(Method.java:521)
04-01 21:56:16.376: E/AndroidRuntime(280):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-01 21:56:16.376: E/AndroidRuntime(280):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-01 21:56:16.376: E/AndroidRuntime(280):  at dalvik.system.NativeStart.main(Native Method)
04-01 21:56:16.376: E/AndroidRuntime(280): Caused by: java.lang.ClassNotFoundException: com.MyApps.TestApp.TestAppActivity in loader dalvik.system.PathClassLoader[/data/app/com.MyApps.TestApp-1.apk]
04-01 21:56:16.376: E/AndroidRuntime(280):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-01 21:56:16.376: E/AndroidRuntime(280):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-01 21:56:16.376: E/AndroidRuntime(280):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-01 21:56:16.376: E/AndroidRuntime(280):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-01 21:56:16.376: E/AndroidRuntime(280):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
04-01 21:56:16.376: E/AndroidRuntime(280):  ... 11 more

List of used:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.MyApps.TestApp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".TestAppActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

I try to replace the entire package name with Testappactivity, but no luck However, it works when I extend testappactivity from activity instead of basegameactivity

Any help appreciated, Sammy

Solution

Error: unable to resolve the superclass of LCOM / myapps / testapp / testappactivity, and it works when you inherit from activity, which indicates that you do not include andengine Library in APK - so basegameactivity cannot be found at run time

Ensure that the andengine dependency is located in the LIBS directory of the Android project; Not just add to the eclipse classpath

In fact, if you have the latest Android eclipse plug-ins, if you just put them in LIBS, any dependencies will be automatically included in your APK

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>