我在基于 OpenGL ES 10 的新项目中收到此错误:
09-03 12:44:07.870: W/dalvikvm(599): Unable to resolve superclass of Lcom/example/basicgl10test/MainActivity; (416)
09-03 12:44:07.870: W/dalvikvm(599): Link of class 'Lcom/example/basicgl10test/MainActivity;' failed
09-03 12:44:07.870: D/AndroidRuntime(599): Shutting down VM
09-03 12:44:07.910: W/dalvikvm(599): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
09-03 12:44:07.920: I/dalvikvm(599): Wrote stack traces to '/data/anr/traces.txt'
09-03 12:44:07.980: E/AndroidRuntime(599): FATAL EXCEPTION: main
09-03 12:44:07.980: E/AndroidRuntime(599): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.basicgl10test/com.example.basicgl10test.MainActivity}: java.lang.ClassNotFoundException: com.example.basicgl10test.MainActivity
09-03 12:44:07.980: E/AndroidRuntime(599): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
09-03 12:44:07.980: E/AndroidRuntime(599): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-03 12:44:07.980: E/AndroidRuntime(599): at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-03 12:44:07.980: E/AndroidRuntime(599): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-03 12:44:07.980: E/AndroidRuntime(599): at android.os.Handler.dispatchMessage(Handler.java:99)
09-03 12:44:07.980: E/AndroidRuntime(599): at android.os.Looper.loop(Looper.java:137)
09-03 12:44:07.980: E/AndroidRuntime(599): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-03 12:44:07.980: E/AndroidRuntime(599): at java.lang.reflect.Method.invokeNative(Native Method)
09-03 12:44:07.980: E/AndroidRuntime(599): at java.lang.reflect.Method.invoke(Method.java:511)
09-03 12:44:07.980: E/AndroidRuntime(599): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-03 12:44:07.980: E/AndroidRuntime(599): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-03 12:44:07.980: E/AndroidRuntime(599): at dalvik.system.NativeStart.main(Native Method)
09-03 12:44:07.980: E/AndroidRuntime(599): Caused by: java.lang.ClassNotFoundException: com.example.basicgl10test.MainActivity
09-03 12:44:07.980: E/AndroidRuntime(599): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
09-03 12:44:07.980: E/AndroidRuntime(599): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-03 12:44:07.980: E/AndroidRuntime(599): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-03 12:44:07.980: E/AndroidRuntime(599): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
09-03 12:44:07.980: E/AndroidRuntime(599): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
09-03 12:44:07.980: E/AndroidRuntime(599): ... 11 more
09-03 12:44:08.061: W/ActivityManager(92): Force finishing activity com.example.basicgl10test/.MainActivity
我的活动课是这样的:
package com.example.basicgl10test;
import com.example.gl10gameadvlib.GL10GameActivity;
import com.example.gl10gameadvlib.Screen;
public class MainActivity extends GL10GameActivity {
父活动在另一个包中是这样的:
package com.example.gl10gameadvlib;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
public abstract class GL10GameActivity extends Activity {
构建过程中没有错误。我重新创建了一个新项目,clean+build,问题仍然存在。
我正在使用带有 Android 4.0 模拟器的 Eclipse IDE。问题存在于任何模拟器或真实设备上。
谢谢苏维克