2012-05-09 23 views
-2

我只是複製從AndEngine主頁的例子,但應用程序總是被迫停止在​​仿真器:((請幫我 這裏是主要acitvity:AndEngine:樣品例如不工作

public class HelloMe extends BaseGameActivity { 

    private static final int CAMERA_WIDTH = 720; 

    private static final int CAMERA_HEIGHT = 480; 

    // =========================================================== 
    // Fields 
    // =========================================================== 

    private Camera mCamera; 
    private BitmapTextureAtlas mFontTexture; 
    private Font mFont; 

@Override 
public Engine onLoadEngine() { 
    // TODO Auto-generated method stub 
    this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT); 
     return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera)); 

} 

@Override 
public void onLoadResources() { 
    // TODO Auto-generated method stub 
    this.mFontTexture = new BitmapTextureAtlas(256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA); 

    this.mFont = new Font(this.mFontTexture, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 32, true, Color.BLACK); 

    this.mEngine.getTextureManager().loadTexture(this.mFontTexture); 
    this.getFontManager().loadFont(this.mFont); 

} 

@Override 
public Scene onLoadScene() { 

    this.mEngine.registerUpdateHandler(new FPSLogger()); 

    final Scene scene = new Scene(); 
    scene.setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f)); 

    final Text textCenter = new Text(100, 60, this.mFont, "Hello AndEngine!\nYou can even have multilined text!", HorizontalAlign.CENTER); 
    final Text textLeft = new Text(100, 200, this.mFont, "Also left aligned!\nLorem ipsum dolor sit amat...", HorizontalAlign.LEFT); 
    final Text textRight = new Text(100, 340, this.mFont, "And right aligned!\nLorem ipsum dolor sit amat...", HorizontalAlign.RIGHT); 

    scene.attachChild(textCenter); 
    scene.attachChild(textLeft); 
    scene.attachChild(textRight); 

    return scene; 
} 

@Override 
public void onLoadComplete() { 
    // TODO Auto-generated method stub 

} 

} 

而且清單文件:?

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

<uses-sdk android:minSdkVersion="15" /> 

<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" > 
    <activity 
     android:name=".HelloMe" 
     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> 

我使用的Android 4.0.3,並andengine.jar已添加到構建路徑可以AndEngine了Android 2.2只能運行預先感謝:d

PS :Th是的堆棧跟蹤:

 05-09 22:04:08.311: E/AndroidRuntime(628): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.hello/com.hello.HelloMe}: java.lang.ClassNotFoundException: com.hello.HelloMe 
     05-09 22:04:08.311: E/AndroidRuntime(628): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at android.app.ActivityThread.access$600(ActivityThread.java:123) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at android.os.Handler.dispatchMessage(Handler.java:99) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at android.os.Looper.loop(Looper.java:137) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at android.app.ActivityThread.main(ActivityThread.java:4424) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at java.lang.reflect.Method.invokeNative(Native Method) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at java.lang.reflect.Method.invoke(Method.java:511) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at dalvik.system.NativeStart.main(Native Method) 
     05-09 22:04:08.311: E/AndroidRuntime(628): Caused by: java.lang.ClassNotFoundException: com.hello.HelloMe 
     05-09 22:04:08.311: E/AndroidRuntime(628): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at android.app.Instrumentation.newActivity(Instrumentation.java:1023) 
     05-09 22:04:08.311: E/AndroidRuntime(628): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871) 
+0

什麼是堆棧跟蹤? – 2012-05-09 15:30:01

+0

HelloMe類的包名稱是什麼? – VinceFR

+0

默認情況下,它是com.hello。 – wanting252

回答

2

AndEngine,您正在使用犯規看起來像最近的一次,不支持仿真器的版本。嘗試插入手機並運行它,它可能會起作用。

+0

好的,這是對我來說最好的答案:((我把手機插進去,它的功能就像一個魅力:)感謝您的幫助:) – wanting252

+0

實際上,它支持模擬器,只需要啓用一些虛擬選項設備 –

0

添加「libs」文件夾並複製andengine.jar並編譯。