-2

可能重复:
应用程序意外停止:mrsnakey

大家好,我对编程很陌生,最近借了 Mario Zechner 的《Beginning Android Games》一书。他教我如何创建一个名为 mr nom 的游戏。我遵循每一条指令,并将 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);
    }




}

我的安卓游戏文件

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

只有这些给了我一个框,上面写着“附加来源”

谢谢阅读!感谢提供的任何帮助:)

4

1 回答 1

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

这是您的应用程序失败的关键。

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

于 2012-04-25T15:43:59.007 回答