Android 特定于设备的崩溃

Android 特定于设备的崩溃,android,Android,我的应用程序在一行非常奇怪的代码上崩溃了,这似乎没有什么问题……事实上,这在大多数设备上都有效,但在我的nexus 7(这是我测试过的唯一一款平板电脑,仔细想想) 这是它正在破解的一行代码 findViewById(R.id.btbutton).setVisibility(View.GONE); 它位于恢复时的onResume 这是堆栈跟踪 12-11 18:06:52.955 5674-5674/com.blank.blank E/AndroidRuntime﹕ FATAL EXCEP

我的应用程序在一行非常奇怪的代码上崩溃了,这似乎没有什么问题……事实上,这在大多数设备上都有效,但在我的nexus 7(这是我测试过的唯一一款平板电脑,仔细想想)

这是它正在破解的一行代码

findViewById(R.id.btbutton).setVisibility(View.GONE);
它位于恢复时的
onResume

这是堆栈跟踪

12-11 18:06:52.955    5674-5674/com.blank.blank E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.blank.blank, PID: 5674
    java.lang.RuntimeException: Unable to resume activity {com.blank.blank/com.blank.blank.activities.MerchantListActivity}: java.lang.NullPointerException
            at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2774)
            at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2803)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2238)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at 

    com.blank.blank.activities.MerchantListActivity.onResume(MerchantListActivity.java:164)
                at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192)
                at android.app.Activity.performResume(Activity.java:5310)
                at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2764)
                at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2803)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2238)
                at android.app.ActivityThread.access$800(ActivityThread.java:135)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                at android.os.Handler.dispatchMessage(Handler.java:102)
                at android.os.Looper.loop(Looper.java:136)
                at android.app.ActivityThread.main(ActivityThread.java:5001)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:515)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                at dalvik.system.NativeStart.main(Native Method)
请记住,这在其他设备上也适用。我已经尝试为代码行创建一个按钮变量,并设置其可见性,我已经检查了内容布局是否正确,我已经检查了xml中的变量名是否与活动中的名称匹配。如果我将该行注释掉,它也会出现在
onResume

谢谢你的帮助

以防万一,这里是xml

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1">

    <fragment
        android:id="@+id/merchant_list"
        android:name="com.blank.blank.fragments.MerchantListFragment"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:tag="ly.wise.ProgramList"
        tools:layout="@android:layout/list_content" />
    <Button android:id="@+id/statuscalcbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Calculating Status"
        android:minHeight="0dp"
        android:background="@color/blue_wisely"
        android:textColor="@color/white_opaque"
        android:padding="2dp"
        android:visibility="gone"/>
    <Button android:id="@+id/calcexplain"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="We'll notify you when we're done"
        android:minHeight="0dp"
        android:background="@color/blue"
        android:textColor="@color/white_opaque"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:padding="2dp"
        android:visibility="gone"/>
    <Button android:id="@+id/btbutton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Turn On Bluetooth"
        android:background="@color/blue"
        android:textColor="@color/white_opaque"
        android:visibility="visible"/>
    <Button android:id="@+id/btbuttonexplain"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Tap to learn why"
        android:minHeight="0dp"
        android:background="@color/blue"
        android:textColor="@color/white_opaque"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:padding="2dp"
        android:visibility="visible"/>
</LinearLayout>

我不确定这是否有帮助,但我会尝试先将按钮声明为按钮,然后设置可见性:

btbutton = (Button)findViewById(R.id.btbutton);
btbutton.setVisibility(View.GONE);

.我们能看到活动代码吗?您使用的其他设备是否有不同的Android版本?
btbutton = (Button)findViewById(R.id.btbutton);
btbutton.setVisibility(View.GONE);