-2
03-04 11:09:41.524: E/AndroidRuntime(943): FATAL EXCEPTION: main
03-04 11:09:41.524: E/AndroidRuntime(943): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.otobusumnerede/com.otobusumnerede.AyarlarActivity}: java.lang.NullPointerException
03-04 11:09:41.524: E/AndroidRuntime(943):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-04 11:09:41.524: E/AndroidRuntime(943):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-04 11:09:41.524: E/AndroidRuntime(943):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-04 11:09:41.524: E/AndroidRuntime(943):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-04 11:09:41.524: E/AndroidRuntime(943):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-04 11:09:41.524: E/AndroidRuntime(943):  at android.os.Looper.loop(Looper.java:137)
03-04 11:09:41.524: E/AndroidRuntime(943):  at android.app.ActivityThread.main(ActivityThread.java:5041)
03-04 11:09:41.524: E/AndroidRuntime(943):  at java.lang.reflect.Method.invokeNative(Native Method)
03-04 11:09:41.524: E/AndroidRuntime(943):  at java.lang.reflect.Method.invoke(Method.java:511)
03-04 11:09:41.524: E/AndroidRuntime(943):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-04 11:09:41.524: E/AndroidRuntime(943):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-04 11:09:41.524: E/AndroidRuntime(943):  at dalvik.system.NativeStart.main(Native Method)
03-04 11:09:41.524: E/AndroidRuntime(943): Caused by: java.lang.NullPointerException
03-04 11:09:41.524: E/AndroidRuntime(943):  at com.otobusumnerede.AyarlarActivity.onCreate(AyarlarActivity.java:24)
03-04 11:09:41.524: E/AndroidRuntime(943):  at android.app.Activity.performCreate(Activity.java:5104)
03-04 11:09:41.524: E/AndroidRuntime(943):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-04 11:09:41.524: E/AndroidRuntime(943):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-04 11:09:41.524: E/AndroidRuntime(943):  ... 11 more
03-04 11:24:14.452: E/Trace(1311): error opening trace file: No such file or directory (2)
03-04 11:24:44.843: E/AndroidRuntime(1311): FATAL EXCEPTION: main
03-04 11:24:44.843: E/AndroidRuntime(1311): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.otobusumnerede/com.otobusumnerede.AyarlarActivity}: java.lang.NullPointerException
03-04 11:24:44.843: E/AndroidRuntime(1311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at android.os.Looper.loop(Looper.java:137)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at android.app.ActivityThread.main(ActivityThread.java:5041)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at java.lang.reflect.Method.invokeNative(Native Method)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at java.lang.reflect.Method.invoke(Method.java:511)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at dalvik.system.NativeStart.main(Native Method)
03-04 11:24:44.843: E/AndroidRuntime(1311): Caused by: java.lang.NullPointerException
03-04 11:24:44.843: E/AndroidRuntime(1311):     at com.otobusumnerede.AyarlarActivity.onCreate(AyarlarActivity.java:25)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at android.app.Activity.performCreate(Activity.java:5104)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-04 11:24:44.843: E/AndroidRuntime(1311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-04 11:24:44.843: E/AndroidRuntime(1311):     ... 11 more
4

1 に答える 1

0

アクティビティからテキストをコピーして貼り付けるか、少なくともコードの 25 行目を貼り付けることができれば、簡単にサポートできます。

アクティビティの早い段階で通り過ぎるので、onCreate()最初に確認してください

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.yourlayoutxml);
imageView = (ImageView) findViewById(R.id.yourimageviewid); //just an example  
  1. 必ず事前にお電話setContentView()くださいfindViewById
  2. 宣言したかどうかを確認し、変数を適切に初期化しました
  3. その場合は、null の可能性がある値を探します
于 2014-03-04T13:14:20.603 に答える