-1

私はAndroid開発に不慣れで、Eclipseで最初のアプリを実行しようとしましたが、エミュレーターでエラーが発生しました:

アプリケーション XXXXX (プロセス com.ough.XXXXX) が予期せず停止しました。もう一度お試しください。

Webで答えを探してみましたが、あまり役に立たないようです。多分私はエミュレータを間違って設定しましたか?または私のコードは良くありませんか?

私のエミュレータは次のように設定されています: 4.0" WVGA , android 2.2 api level 8 (私は別のものを試しましたが、うまくいきません..)

私のコードは:

int counter;
Button add;
Button sub;
TextView display;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    counter = 0;
    add = (Button) findViewById(R.id.bAdd);
    sub = (Button) findViewById(R.id.bSub);
    display = (TextView) findViewById(R.id.tvDisplay);

    add.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            counter++;
            display.setText("Your total is " + counter);
        }
    });

    sub.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            counter--;
            display.setText("Your total is " + counter);
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

私の androidManifest.xml :

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.ough.thenewboston.MainActivity"
        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>

ログキャット:

    03-19 13:31:19.014: E/Zygote(32): setreuid() failed. errno: 2
03-19 13:31:24.084: E/Zygote(32): setreuid() failed. errno: 17
03-19 13:31:24.844: E/BatteryService(58): usbOnlinePath not found
03-19 13:31:24.844: E/BatteryService(58): batteryVoltagePath not found
03-19 13:31:24.844: E/BatteryService(58): batteryTemperaturePath not found
03-19 13:31:24.854: E/SurfaceFlinger(58): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
03-19 13:31:28.244: E/EventHub(58): could not get driver version for /dev/input/mouse0, Not a typewriter
03-19 13:31:28.244: E/EventHub(58): could not get driver version for /dev/input/mice, Not a typewriter
03-19 13:31:28.914: E/System(58): Failure starting core service
03-19 13:31:28.914: E/System(58): java.lang.SecurityException
03-19 13:31:28.914: E/System(58):   at android.os.BinderProxy.transact(Native Method)
03-19 13:31:28.914: E/System(58):   at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
03-19 13:31:28.914: E/System(58):   at android.os.ServiceManager.addService(ServiceManager.java:72)
03-19 13:31:28.914: E/System(58):   at com.android.server.ServerThread.run(SystemServer.java:184)
03-19 13:31:29.334: E/SoundPool(58): error loading /system/media/audio/ui/Effect_Tick.ogg
03-19 13:31:29.334: E/SoundPool(58): error loading /system/media/audio/ui/KeypressStandard.ogg
03-19 13:31:29.334: E/SoundPool(58): error loading /system/media/audio/ui/KeypressSpacebar.ogg
03-19 13:31:29.334: E/SoundPool(58): error loading /system/media/audio/ui/KeypressDelete.ogg
03-19 13:31:29.334: E/SoundPool(58): error loading /system/media/audio/ui/KeypressReturn.ogg
03-19 13:31:30.024: E/ThrottleService(58): Could not open GPS configuration file /etc/gps.conf
03-19 13:31:30.464: E/logwrapper(131): executing /system/bin/tc failed: No such file or directory
03-19 13:31:30.504: E/logwrapper(133): executing /system/bin/tc failed: No such file or directory
03-19 13:31:30.574: E/logwrapper(136): executing /system/bin/tc failed: No such file or directory
03-19 13:31:35.136: E/HierarchicalStateMachine(58): TetherMaster - unhandledMessage: msg.what=3

もう1つ奇妙です。アプリケーションを起動するたびに「ロック」されます。ロックモードから開くと、「申し訳ありません..」というエラー行が表示されます..

何かご意見は ?

4

1 に答える 1

1

logcatを表示していないため、これは直接的な回答ではありません。コードに明らかな問題は見られませんが、役に立ち、コメントするには多すぎることを願っています。そうでない場合は削除します。

それが起動しない場合、あなたが持っているコードでは、null pointer exceptionあなたのmanifest.

ステップスルーして、これらの行がないことを確認してくださいnull

add = (Button) findViewById(R.id.bAdd);
sub = (Button) findViewById(R.id.bSub);
display = (TextView) findViewById(R.id.tvDisplay);

また、権利を宣言したことを確認してくださいmenu layout

値が表示されない場合null、問題はおそらくあなたのmanifest

ログキャット

「デバイスが切断されました」と表示されたら、コンソールタブにいると確信しています。logcat タブにいる必要があります。最初の行を選択し、Shift キーを押しながら最後の行を選択し、[保存] アイコンをクリックしてログを保存し、それをコピーして OP に貼り付けることができます。

于 2013-03-19T13:20:44.303 に答える