我尝试了使用 andeninge 的小游戏。它在 Window XP 系统中工作。如果我使用 andeninge 导入或创建新项目,则相同的项目会出现运行时错误,例如
07-25 17:34:43.854: E/AndroidRuntime(280): FATAL EXCEPTION: main
07-25 17:34:43.854: E/AndroidRuntime(280): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.m2f/com.m2f.AndengineActivity}: java.lang.NullPointerException
07-25 17:34:43.854: E/AndroidRuntime(280): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-25 17:34:43.854: E/AndroidRuntime(280): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-25 17:34:43.854: E/AndroidRuntime(280): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-25 17:34:43.854: E/AndroidRuntime(280): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-25 17:34:43.854: E/AndroidRuntime(280): at android.os.Handler.dispatchMessage(Handler.java:99)
07-25 17:34:43.854: E/AndroidRuntime(280): at android.os.Looper.loop(Looper.java:123)
07-25 17:34:43.854: E/AndroidRuntime(280): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-25 17:34:43.854: E/AndroidRuntime(280): at java.lang.reflect.Method.invokeNative(Native Method)
07-25 17:34:43.854: E/AndroidRuntime(280): at java.lang.reflect.Method.invoke(Method.java:521)
07-25 17:34:43.854: E/AndroidRuntime(280): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-25 17:34:43.854: E/AndroidRuntime(280): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-25 17:34:43.854: E/AndroidRuntime(280): at dalvik.system.NativeStart.main(Native Method)
07-25 17:34:43.854: E/AndroidRuntime(280): Caused by: java.lang.NullPointerException
07-25 17:34:43.854: E/AndroidRuntime(280): at org.anddev.andengine.ui.activity.BaseGameActivity.onCreate(BaseGameActivity.java:50)
07-25 17:34:43.854: E/AndroidRuntime(280): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-25 17:34:43.854: E/AndroidRuntime(280): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
示例代码:
public class DemoGame1 extends BaseGameActivity {
@Override
public void onLoadComplete() {
// TODO Auto-generated method stub
}
@Override
public Engine onLoadEngine() {
// TODO Auto-generated method stub
return null;
}
@Override
public void onLoadResources() {
// TODO Auto-generated method stub
}
@Override
public Scene onLoadScene() {
// TODO Auto-generated method stub
return null;
}
}
但 android 应用程序运行良好(其打印 HelloWorld)。