問題を抱えている人がたくさんいることを私は知っています。私は見つけることができる多くの方法を試しましたが、それでもエラーが発生します。
- アクティビティは1つだけで、登録されています。
- com.hermione.woodenfish.MainActivityによって.MainActivityを完了しようとしましたが、使用できません
- クリーンアップと再構築も機能しません
本当に助けが必要です、ありがとう!
LogCat:
08-01 12:09:33.944: E/Trace(1032): error opening trace file: No such file or directory (2)
08-01 12:09:34.384: D/AndroidRuntime(1032): Shutting down VM
08-01 12:09:34.424: W/dalvikvm(1032): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-01 12:09:34.465: E/AndroidRuntime(1032): FATAL EXCEPTION: main
08-01 12:09:34.465: E/AndroidRuntime(1032): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.hermione.woodenfish/com.hermione.woodenfish.MainActivity}: java.lang.NullPointerException
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.os.Looper.loop(Looper.java:137)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-01 12:09:34.465: E/AndroidRuntime(1032): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 12:09:34.465: E/AndroidRuntime(1032): at java.lang.reflect.Method.invoke(Method.java:511)
08-01 12:09:34.465: E/AndroidRuntime(1032): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-01 12:09:34.465: E/AndroidRuntime(1032): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-01 12:09:34.465: E/AndroidRuntime(1032): at dalvik.system.NativeStart.main(Native Method)
08-01 12:09:34.465: E/AndroidRuntime(1032): Caused by: java.lang.NullPointerException
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.content.ContextWrapper.getResources(ContextWrapper.java:81)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.media.MediaPlayer.create(MediaPlayer.java:824)
08-01 12:09:34.465: E/AndroidRuntime(1032): at com.hermione.woodenfish.MainActivity.<init>(MainActivity.java:24)
08-01 12:09:34.465: E/AndroidRuntime(1032): at java.lang.Class.newInstanceImpl(Native Method)
08-01 12:09:34.465: E/AndroidRuntime(1032): at java.lang.Class.newInstance(Class.java:1319)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
08-01 12:09:34.465: E/AndroidRuntime(1032): ... 11 more
08-01 12:33:02.784: E/Trace(1171): error opening trace file: No such file or directory (2)
08-01 12:33:03.125: D/AndroidRuntime(1171): Shutting down VM
08-01 12:33:03.125: W/dalvikvm(1171): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-01 12:33:03.154: E/AndroidRuntime(1171): FATAL EXCEPTION: main
08-01 12:33:03.154: E/AndroidRuntime(1171): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.hermione.woodenfish/com.hermione.woodenfish.MainActivity}: java.lang.NullPointerException
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.os.Looper.loop(Looper.java:137)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-01 12:33:03.154: E/AndroidRuntime(1171): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 12:33:03.154: E/AndroidRuntime(1171): at java.lang.reflect.Method.invoke(Method.java:511)
08-01 12:33:03.154: E/AndroidRuntime(1171): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-01 12:33:03.154: E/AndroidRuntime(1171): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-01 12:33:03.154: E/AndroidRuntime(1171): at dalvik.system.NativeStart.main(Native Method)
08-01 12:33:03.154: E/AndroidRuntime(1171): Caused by: java.lang.NullPointerException
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.content.ContextWrapper.getResources(ContextWrapper.java:81)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.media.MediaPlayer.create(MediaPlayer.java:824)
08-01 12:33:03.154: E/AndroidRuntime(1171): at com.hermione.woodenfish.MainActivity.<init>(MainActivity.java:23)
08-01 12:33:03.154: E/AndroidRuntime(1171): at java.lang.Class.newInstanceImpl(Native Method)
08-01 12:33:03.154: E/AndroidRuntime(1171): at java.lang.Class.newInstance(Class.java:1319)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
08-01 12:33:03.154: E/AndroidRuntime(1171): ... 11 more
MainActivity.java
package com.hermione.woodenfish;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
private MediaPlayer mp = MediaPlayer.create(this, R.raw.knok);
public void sendKnok(View view) {
if (mp.isPlaying()){
mp.stop();
}
mp.start();
}
}
マニフェスト:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hermione.woodenfish"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>