应用程序意外停止请再次尝试Android

时间:2012-04-25 15:36:47

标签: java javascript android android-emulator

  

可能重复:
  The application has stopped unexpectedly : mrsnakey

大家好,我是编程新手,最近借用了Mario Zechner的“Beginning Android Games”一书。他告诉我如何创建一个名为mr nom的游戏。我遵循了每一条指令,并将名字改名为mrsnakey。

我的logcat错误如下:

 04-25 08:37:16.422: I/Process(856): Sending signal. PID: 856 SIG: 9
04-25 08:39:58.712: W/dalvikvm(863): Unable to resolve superclass of Lcom/zardtechnologies/mrsnakey/MrSnakey; (15)
04-25 08:39:58.752: W/dalvikvm(863): Link of class 'Lcom/zardtechnologies/mrsnakey/MrSnakey;' failed
04-25 08:39:58.752: D/AndroidRuntime(863): Shutting down VM
04-25 08:39:58.752: W/dalvikvm(863): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-25 08:39:58.792: E/AndroidRuntime(863): FATAL EXCEPTION: main
04-25 08:39:58.792: E/AndroidRuntime(863): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.zardtechnologies.mrsnakey/com.zardtechnologies.mrsnakey.MrSnakey}: java.lang.ClassNotFoundException: com.zardtechnologies.mrsnakey.MrSnakey in loader dalvik.system.PathClassLoader[/data/app/com.zardtechnologies.mrsnakey-2.apk]
04-25 08:39:58.792: E/AndroidRuntime(863):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
04-25 08:39:58.792: E/AndroidRuntime(863):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-25 08:39:58.792: E/AndroidRuntime(863):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-25 08:39:58.792: E/AndroidRuntime(863):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-25 08:39:58.792: E/AndroidRuntime(863):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-25 08:39:58.792: E/AndroidRuntime(863):  at android.os.Looper.loop(Looper.java:123)
04-25 08:39:58.792: E/AndroidRuntime(863):  at android.app.ActivityThread.main(ActivityThread.java:4627)
04-25 08:39:58.792: E/AndroidRuntime(863):  at java.lang.reflect.Method.invokeNative(Native Method)
04-25 08:39:58.792: E/AndroidRuntime(863):  at java.lang.reflect.Method.invoke(Method.java:521)
04-25 08:39:58.792: E/AndroidRuntime(863):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-25 08:39:58.792: E/AndroidRuntime(863):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-25 08:39:58.792: E/AndroidRuntime(863):  at dalvik.system.NativeStart.main(Native Method)
04-25 08:39:58.792: E/AndroidRuntime(863): Caused by: java.lang.ClassNotFoundException: com.zardtechnologies.mrsnakey.MrSnakey in loader dalvik.system.PathClassLoader[/data/app/com.zardtechnologies.mrsnakey-2.apk]
04-25 08:39:58.792: E/AndroidRuntime(863):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-25 08:39:58.792: E/AndroidRuntime(863):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-25 08:39:58.792: E/AndroidRuntime(863):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-25 08:39:58.792: E/AndroidRuntime(863):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-25 08:39:58.792: E/AndroidRuntime(863):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
04-25 08:39:58.792: E/AndroidRuntime(863):  ... 11 more

我的清单在这里:

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

    <application
        android:debuggable="true"
        android:icon="@drawable/ic_launcher"
        android:label="Mr.Snakey" >
        <activity
            android:name=".MrSnakey"
            android:configChanges="keyboard|keyboardHidden|orientation"
            android:label="Mr.Snakey"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-sdk
        android:minSdkVersion="3"
        android:targetSdkVersion="12" />

</manifest>

我的活动在这里:

package com.zardtechnologies.mrsnakey;

import com.zardapps.framework.Screen;
import com.zardtechnologies.androidgames.framework.impl.AndroidGame;

public class MrSnakey extends AndroidGame {

    public Screen getStartScreen() {
        return new LoadingScreen(this);
    }




}

我的AndroidGame文件

package com.zardtechnologies.androidgames.framework.impl;

import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.view.Window;
import android.view.WindowManager;

import com.zardapps.framework.Audio;
import com.zardapps.framework.FileIO;
import com.zardapps.framework.Game;
import com.zardapps.framework.Graphics;
import com.zardapps.framework.Input;
import com.zardapps.framework.Screen;

public abstract class AndroidGame extends Activity implements Game {
    AndroidFastRenderView renderView;
    Graphics graphics;
    Audio audio;
    Input input;
    FileIO fileIO;
    Screen screen;
    WakeLock wakeLock;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
        int frameBufferWidth = isLandscape ? 480 : 320;
        int frameBufferHeight = isLandscape ? 320 : 480;
        Bitmap frameBuffer = Bitmap.createBitmap(frameBufferWidth,
                frameBufferHeight, Config.RGB_565);

        float scaleX = (float) frameBufferWidth
                / getWindowManager().getDefaultDisplay().getWidth();
        float scaleY = (float) frameBufferHeight
                / getWindowManager().getDefaultDisplay().getHeight();

        renderView = new AndroidFastRenderView(this, frameBuffer);
        graphics = new AndroidGraphics(getAssets(), frameBuffer);
        fileIO = new AndroidFileIO(getAssets());
        audio = new AndroidAudio(this);
        input = new AndroidInput(this, renderView, scaleX, scaleY);
        screen = getStartScreen();
        setContentView(renderView);

        PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
        wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK,
                "GLGAME");

    }

    public void onResume() {
        super.onResume();
        wakeLock.acquire();
        screen.resume();
        renderView.resume();
    }

    public void onPause() {
        super.onPause();
        wakeLock.release();
        renderView.pause();
        screen.pause();

        if (isFinishing())
            screen.dispose();
    }

    public Input getInput() {
        return input;
    }

    public FileIO getFileIO() {
        return fileIO;
    }

    public Graphics getGraphics() {
        return graphics;
    }

    public Audio getAudio() {
        return audio;
    }

    public void setScreen(Screen screen) {
        if (screen == null)
            throw new IllegalArgumentException("Screen must not be null");
        this.screen.pause();
        this.screen.dispose();
        screen.resume();
        screen.update(0);
        this.screen = screen;
    }

    public Screen getCurrentScreen() {
        return screen;
    }
}

哦,另一个注意事项我搜索了网络,很多人说要调试。我调试了它,我得到了这个:

Mr.Snakey [Android Application] 
    DalvikVM[localhost:8631]    
        Thread [<1> main] (Suspended (exception RuntimeException))  
            ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2585  
            ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2679   
            ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 125 
            ActivityThread$H.handleMessage(Message) line: 2033  
            ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
            Looper.loop() line: 123 
            ActivityThread.main(String[]) line: 4627    
            Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
            Method.invoke(Object, Object...) line: 521  
            ZygoteInit$MethodAndArgsCaller.run() line: 868  
            ZygoteInit.main(String[]) line: 626 
            NativeStart.main(String[]) line: not available [native method]  
        Thread [<6> Binder Thread #2] (Running) 
        Thread [<5> Binder Thread #1] (Running) 

有关如何阅读本文的任何提示?只有

Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  

                ActivityThread$H(Handler).dispatchMessage(Message) line: 99

只有这些给了我一个说“附加来源”的方框

感谢阅读! 感谢给予的任何帮助:)

1 个答案:

答案 0 :(得分:0)

Unable to resolve superclass of Lcom/zardtechnologies/mrsnakey/MrSnakey; (15)

这是您的应用失败的关键所在。

我建议将两个类的AndroidGame和Game移动到与MrSnakey(com.zardtechnologies.mrsnakey)相同的包中并尝试。在加载MrSnakey时,Dalvik如何无法链接你的超级班级。