活动不适用于4.3和4.4.2

时间:2014-05-15 22:50:03

标签: android button android-4.4-kitkat android-4.3-jelly-bean

我的活动只有一些按钮。当我点击其中一个出现警报对话框。 它适用于2.3.6,4.0.3和4.1.2,但在4.3和4.4.2中我遇到了问题。

我的错误:

05-15 19:15:23.145: E/AndroidRuntime(16247): FATAL EXCEPTION: main
05-15 19:15:23.145: E/AndroidRuntime(16247): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.MYPROJECT/br.com.MYPROJECT.MYACTIVITY}: java.lang.NullPointerException
05-15 19:15:23.145: E/AndroidRuntime(16247):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at android.app.ActivityThread.access$700(ActivityThread.java:159)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at android.os.Looper.loop(Looper.java:176)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at android.app.ActivityThread.main(ActivityThread.java:5419)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at java.lang.reflect.Method.invokeNative(Native Method)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at java.lang.reflect.Method.invoke(Method.java:525)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at dalvik.system.NativeStart.main(Native Method)
05-15 19:15:23.145: E/AndroidRuntime(16247): Caused by: java.lang.NullPointerException
05-15 19:15:23.145: E/AndroidRuntime(16247):    at br.com.MYPROJECT.MYACTIVITY.onCreate(Padroeiros.java:139)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at android.app.Activity.performCreate(Activity.java:5372)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
05-15 19:15:23.145: E/AndroidRuntime(16247):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)

2 个答案:

答案 0 :(得分:0)

Caused by: java.lang.NullPointerException at br.com.MYPROJECT.MYACTIVITY.onCreate(Padroeiros.java:139)

你在Padroeiros.java第139行有一个空指针异常

答案 1 :(得分:0)

check  your  manifest  

您的应用包和您的活动包可能会有所不同。 但在这种情况下,请在名称属性中使用活动完整路径

例如:

   <activity
            android:name="br.com.MYPROJECT.MYACTIVITY"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize" >
        </activity>