0

私はEclipseで(Windowsで)アンドロイドゲームを作ろうとしています。エミュレーターと電話の両方でプログラムを実行すると、nulpointerexceptions と classcastexceptions が発生し続けます。それぞれ独自のxmlレイアウトを持つ2つのクラス(アクティビティ)があります。主な活動は完全に実行されます。ただし、2番目のアクティビティを次のように起動すると:

final Intent i = new Intent(this, Arrowscreen.class);
... 
startActivity(i);

前述の例外があります。見つからないソースを常に指します。 WindowsのEclipseでソースをステップスルーする方法はありますか? http://source.android.comを見てきましたが、Windows には解決策がないようです。cygwin の Linux の指示に従おうとしましたが、うまくいかないようです (できれば Windows で作業したいと思います)。

私はまだアンドロイド開発に慣れていないので、何か重要なものを見逃しているかもしれません。このマニフェスト宣言に問題はありますか?:

<activity android:name=".Arrowscreen" 
                android:screenOrientation="landscape"
                android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                android:label="@string/app_name">
        <intent-filter>
                <action android:name="android.intent.action.RUN" />
                <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

コード サンプル全体は長くなるため掲載を控えますが、「postDelayed」を使用してタイマーのメイン ループに加速度計、GPS、ランナブルを使用していることをお伝えします。GPSの細かい位置の許可もマニフェストにあります。私は立ち往生しているので、どんな助けでも大歓迎です。ありがとう!

編集:以下は、実行時例外が発生するコードの一部です

@Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        setContentView(R.layout.arrow);

        img=(ImageView)findViewById(R.id.ArrowBackground);
        arrow1=(ImageView)findViewById(R.id.turningArrow);
        GPSx=(TextView)findViewById(R.id.textView1);
        GPSy=(TextView)findViewById(R.id.textView2);
        MGNTx=(TextView)findViewById(R.id.textView3);
        MGNTy=(TextView)findViewById(R.id.textView4);
        angle = 0;
        lastAngle = 0;
        arrowAngle = 0;
        mValues[0]=0; mValues[1]=0; mValues[2]=0; 

        //mStartTime = System.currentTimeMillis();
        mHandler.removeCallbacks(UpdateArrow);
        mHandler.postDelayed(UpdateArrow, 400);
4

2 に答える 2

1

私があなたの質問を誤解していない限り...

Eclipseで、アクティビティのonCreateの最初の行にブレークポイントを設定し、デバッグモードでアプリを起動します([実行]->[名前を付けて削除]->[Androidアプリケーション])。

これを行うための2つのブログ投稿:1。http : //www.droidnova.com/debugging-in-android-using-eclipse,541.html 2. http://www.latenightpc.com/blog/archives/2007/ 11/21 /starting-a-debug-session-for-android-with-adt

于 2011-04-16T04:46:48.077 に答える
0

「Arrowscreen」クラスが「Activity」クラスを拡張するかどうかを確認してください。そうでない場合は、最初にそれを行ってください...

これが役立つかもしれないと思います。

public class Arrowscreen extends Activity{

…………}

AndroidMainfest.xml で

<activity android:name="Arrowscreen" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.RUN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>

于 2011-04-16T04:55:27.300 に答える