Android游戏没有运行。未知的logcat

时间:2014-03-09 10:08:51

标签: java android andengine

这是我的代码:

package com.example.juggler;

import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.ui.activity.BaseGameActivity;

public class GameActivity extends BaseGameActivity {

    Scene scene;
    protected static final int CAMERA_WIDTH = 480;
    protected static final int CAMERA_HEIGHT = 800;
    BitmapTextureAtlas ballTexture;
    ITextureRegion ballTextureRegion;

    @Override
    public EngineOptions onCreateEngineOptions() {
        // TODO Auto-generated method stub
        Camera mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
        EngineOptions options = new EngineOptions(true,
                ScreenOrientation.PORTRAIT_FIXED, new RatioResolutionPolicy(
                        CAMERA_WIDTH, CAMERA_HEIGHT), mCamera);
        return options;
    }

    @Override
    public void onCreateResources(
            OnCreateResourcesCallback pOnCreateResourcesCallback)
            throws Exception {
        // TODO Auto-generated method stub
        loadGfx();

        pOnCreateResourcesCallback.onCreateResourcesFinished();

    }

    private void loadGfx() {
        // TODO Auto-generated method stub
        BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");

        // width and height power of 2^x
        ballTexture = new BitmapTextureAtlas(getTextureManager(), 32, 32);
        ballTextureRegion = BitmapTextureAtlasTextureRegionFactory
                .createFromAsset(ballTexture, this, "ball.png", 0, 0);
        ballTexture.load();
    }

    @Override
    public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback)
            throws Exception {
        // TODO Auto-generated method stub
        this.scene = new Scene();
        this.scene.setBackground(new Background(0, 125, 58));
        pOnCreateSceneCallback.onCreateSceneFinished(this.scene);
    }

    @Override
    public void onPopulateScene(Scene pScene,
            OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
        // TODO Auto-generated method stub

        Sprite sBall = new Sprite(CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2,
                ballTextureRegion, this.mEngine.getVertexBufferObjectManager());

        this.scene.attachChild(sBall);
        pOnPopulateSceneCallback.onPopulateSceneFinished();

    }

}

这是日志:

03-09 10:02:03.445: D/AndroidRuntime(869): Shutting down VM
03-09 10:02:03.495: W/dalvikvm(869): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-09 10:02:03.555: E/AndroidRuntime(869): FATAL EXCEPTION: main
03-09 10:02:03.555: E/AndroidRuntime(869): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.juggler/com.juggler.Main}: java.lang.ClassNotFoundException: com.juggler.Main in loader dalvik.system.PathClassLoader[/data/app/com.juggler-1.apk]
03-09 10:02:03.555: E/AndroidRuntime(869):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
03-09 10:02:03.555: E/AndroidRuntime(869):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-09 10:02:03.555: E/AndroidRuntime(869):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-09 10:02:03.555: E/AndroidRuntime(869):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-09 10:02:03.555: E/AndroidRuntime(869):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 10:02:03.555: E/AndroidRuntime(869):  at android.os.Looper.loop(Looper.java:123)
03-09 10:02:03.555: E/AndroidRuntime(869):  at android.app.ActivityThread.main(ActivityThread.java:3683)
03-09 10:02:03.555: E/AndroidRuntime(869):  at java.lang.reflect.Method.invokeNative(Native Method)
03-09 10:02:03.555: E/AndroidRuntime(869):  at java.lang.reflect.Method.invoke(Method.java:507)
03-09 10:02:03.555: E/AndroidRuntime(869):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-09 10:02:03.555: E/AndroidRuntime(869):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-09 10:02:03.555: E/AndroidRuntime(869):  at dalvik.system.NativeStart.main(Native Method)
03-09 10:02:03.555: E/AndroidRuntime(869): Caused by: java.lang.ClassNotFoundException: com.juggler.Main in loader dalvik.system.PathClassLoader[/data/app/com.juggler-1.apk]
03-09 10:02:03.555: E/AndroidRuntime(869):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
03-09 10:02:03.555: E/AndroidRuntime(869):  at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
03-09 10:02:03.555: E/AndroidRuntime(869):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-09 10:02:03.555: E/AndroidRuntime(869):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
03-09 10:02:03.555: E/AndroidRuntime(869):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
03-09 10:02:03.555: E/AndroidRuntime(869):  ... 11 more

我不明白问题是什么,我正在使用AndEngine。我不认为问题出在代码中,有什么建议吗?当我运行该程序时,该程序只是没有运行,它说要强行关闭。

谢谢,我认为它会自动改变,但事实并非如此。但现在我遇到了另一个问题。

我的新日志说明了这一点:

03-09 10:51:17.626: D/AndEngine(670): GameActivity.onCreate @(Thread: 'main')
03-09 10:51:17.746: D/dalvikvm(670): Trying to load lib /data/data/com.juggler/lib/libandengine.so 0x40513cd8
03-09 10:51:17.756: D/dalvikvm(670): Added shared lib /data/data/com.juggler/lib/libandengine.so 0x40513cd8
03-09 10:51:17.756: D/dalvikvm(670): No JNI_OnLoad found in /data/data/com.juggler/lib/libandengine.so 0x40513cd8, skipping init
03-09 10:51:17.796: D/AndEngine(670): GameActivity.onResume @(Thread: 'main')
03-09 10:51:17.996: D/libEGL(670): egl.cfg not found, using default config
03-09 10:51:17.996: D/libEGL(670): loaded /system/lib/egl/libGLES_android.so
03-09 10:51:18.096: W/dalvikvm(670): threadid=10: thread exiting with uncaught exception (group=0x40015560)
03-09 10:51:18.096: E/AndroidRuntime(670): FATAL EXCEPTION: GLThread 11
03-09 10:51:18.096: E/AndroidRuntime(670): java.lang.IllegalArgumentException: No EGLConfig found!
03-09 10:51:18.096: E/AndroidRuntime(670):  at org.andengine.opengl.view.ConfigChooser.chooseConfig(ConfigChooser.java:183)
03-09 10:51:18.096: E/AndroidRuntime(670):  at org.andengine.opengl.view.ConfigChooser.chooseConfig(ConfigChooser.java:157)
03-09 10:51:18.096: E/AndroidRuntime(670):  at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:919)
03-09 10:51:18.096: E/AndroidRuntime(670):  at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1264)
03-09 10:51:18.096: E/AndroidRuntime(670):  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
03-09 10:51:18.206: D/AndEngine(670): GameActivity.onPause @(Thread: 'main')
03-09 10:51:19.177: D/AndEngine(670): GameActivity.onDestroy @(Thread: 'main')
03-09 10:51:19.196: D/AndEngine(670): UpdateThread interrupted. Don't worry - this EngineDestroyedException is most likely expected!
03-09 10:51:19.196: D/AndEngine(670): org.andengine.engine.Engine$EngineDestroyedException
03-09 10:51:19.196: D/AndEngine(670):   at org.andengine.engine.Engine.throwOnDestroyed(Engine.java:574)
03-09 10:51:19.196: D/AndEngine(670):   at org.andengine.engine.Engine.onTickUpdate(Engine.java:560)
03-09 10:51:19.196: D/AndEngine(670):   at org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)
03-09 10:51:19.196: D/AndEngine(670): GameActivity.onDestroyResources @(Thread: 'main')
03-09 10:51:19.196: D/AndEngine(670): GameActivity.onGameDestroyed @(Thread: 'main')

0 个答案:

没有答案