これが私が使用しているコードです:
progressFrame = (FrameLayout) findViewById(R.id.progressFrame);
progressFrame.setBackgroundResource(R.drawable.startprogress);
Android 2.3.3ではすべて正常に動作しますが、Android 4では、「setBackgroundResource」行を実行しようとするとクラッシュします。logcatメッセージは次のとおりです。
07-06 17:31:28.159: W/dalvikvm(11848): threadid=1: thread exiting with uncaught exception (group=0x40be81f8)
07-06 17:31:28.167: E/AndroidRuntime(11848): FATAL EXCEPTION: main
07-06 17:31:28.167: E/AndroidRuntime(11848): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bosi.sweetsmell/com.bosi.sweetsmell.activity.RubActivity}: java.lang.NullPointerException
07-06 17:31:28.167: E/AndroidRuntime(11848): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
07-06 17:31:28.167: E/AndroidRuntime(11848): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
07-06 17:31:28.167: E/AndroidRuntime(11848): at android.app.ActivityThread.access$600(ActivityThread.java:128)
07-06 17:31:28.167: E/AndroidRuntime(11848): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
07-06 17:31:28.167: E/AndroidRuntime(11848): at android.os.Handler.dispatchMessage(Handler.java:99)
07-06 17:31:28.167: E/AndroidRuntime(11848): at android.os.Looper.loop(Looper.java:137)
07-06 17:31:28.167: E/AndroidRuntime(11848): at android.app.ActivityThread.main(ActivityThread.java:4514)
07-06 17:31:28.167: E/AndroidRuntime(11848): at java.lang.reflect.Method.invokeNative(Native Method)
07-06 17:31:28.167: E/AndroidRuntime(11848): at java.lang.reflect.Method.invoke(Method.java:511)
07-06 17:31:28.167: E/AndroidRuntime(11848): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
07-06 17:31:28.167: E/AndroidRuntime(11848): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
07-06 17:31:28.167: E/AndroidRuntime(11848): at dalvik.system.NativeStart.main(Native Method)
07-06 17:31:28.167: E/AndroidRuntime(11848): Caused by: java.lang.NullPointerException
07-06 17:31:28.167: E/AndroidRuntime(11848): at com.bosi.sweetsmell.activity.RubActivity.onCreate(RubActivity.java:35)
07-06 17:31:28.167: E/AndroidRuntime(11848): at android.app.Activity.performCreate(Activity.java:4465)
07-06 17:31:28.167: E/AndroidRuntime(11848): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
07-06 17:31:28.167: E/AndroidRuntime(11848): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
07-06 17:31:28.167: E/AndroidRuntime(11848): ... 11 more
誰かが助けてくれることを願っています!