2014-01-17 27 views
1

我的應用程序是使用片段和V4支持片段經理建。該應用程序運行良好,從啓動和實際上我不能自己重新創建這個錯誤,所以原則上我的XML的結構是好的。然而,我的崩潰報告顯示,很多用戶在返回到應用程序時發生崩潰,在暫停後恢復。我得到:拋出:IllegalArgumentException:未找到ID視圖 - 應用上重啓

IllegalArgumentException: No view found for id 0x7f06002d 

請參閱我的XML在下面。報告爲未找到的ID可能會有所不同,它可以是任何嵌套的RelativeLayouts。爲什麼這些觀點隨機消失/未找到?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#F7F5F5" 
    android:orientation="vertical" > 

    <RelativeLayout 
    android:id="@+id/menuLayout" 
    android:layout_width="50dp" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/bottomFragmentLayout" 
    android:layout_alignParentLeft="true" 
    android:visibility="visible" > 

    </RelativeLayout> 

    <RelativeLayout 
    android:id="@+id/whenLayout" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/bottomFragmentLayout" 
    android:layout_toRightOf="@+id/menuLayout" 
    android:visibility="invisible" > 

    </RelativeLayout> 

    <RelativeLayout 
    android:id="@+id/howLayout" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/bottomFragmentLayout" 
    android:layout_toRightOf="@+id/menuLayout" 
    android:visibility="invisible" > 

    </RelativeLayout> 

    <RelativeLayout 
    android:id="@+id/whereLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/bottomFragmentLayout" 
    android:layout_toRightOf="@+id/menuLayout" 
    android:visibility="invisible" > 

    </RelativeLayout> 

    <!-- The bottom bar --> 
    <RelativeLayout 
    android:id="@+id/bottomFragmentLayout" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:background="#999999" > 
    </RelativeLayout> 

</RelativeLayout> 

編輯:全堆棧跟蹤:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.android/com.myapp.android.activity.MainFragmentActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f060030 (com.myapp.android:id/howLayout) for fragment WhatFragment{4220b058 #4 id=0x7f060030 WhatFragment} 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3692) 
    at android.app.ActivityThread.access$700(ActivityThread.java:141) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1240) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:5039) 
    at java.lang.reflect.Method.invokeNative(Method.java) 
    at java.lang.reflect.Method.invoke(Method.java:511) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
    at dalvik.system.NativeStart.main(NativeStart.java) 
Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f060030 (com.myapp.android:id/howLayout) for fragment WhatFragment{4220b058 #4 id=0x7f060030 WhatFragment} 
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919) 
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 
    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 
    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467) 
    at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570) 
    at com.myapp.android.activity.MainFragmentActivity.onStart(MainFragmentActivity.java:449) 
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1164) 
    at android.app.Activity.performStart(Activity.java:5114) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3692) 
    at android.app.ActivityThread.access$700(ActivityThread.java:141) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1240) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:5039) 
    at java.lang.reflect.Method.invokeNative(Method.java) 
    at java.lang.reflect.Method.invoke(Method.java:511) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
    at dalvik.system.NativeStart.main(NativeStart.java) 
+1

你有偶然有一個更完整的崩潰報告嗎?謝謝。 – fasteque

+0

只需編輯並添加堆棧跟蹤,謝謝。 – androidneil

+0

同樣的問題在這裏 - 這個崩潰不會發生在我身上,但我一直在谷歌開發者控制檯提交的崩潰日誌中看到它。我沒有使用支持庫。你有沒有找到這個解決方案? – arlomedia

回答

0
// try this way 
1. when you gave other layout reference like android:layout_above="@+id/bottomFragmentLayout" so here "+" sign removed from reference "+" is for new id declaration so we not declare new id but just gave already define id reference. 
2. in your xml define bottom layout at last and try using this layout id before bottom layout declaration that y it's not finding such kind of layout so you have decalre first layout then gave reference as another layouyt which i correct in my ans.  

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#F7F5F5" 
    android:orientation="vertical" > 

    <RelativeLayout 
     android:id="@+id/bottomFragmentLayout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:background="#999999" > 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/menuLayout" 
     android:layout_width="50dp" 
     android:layout_height="match_parent" 
     android:layout_above="@id/bottomFragmentLayout" 
     android:layout_alignParentLeft="true" 
     android:visibility="visible" > 

    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/whenLayout" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_above="@id/bottomFragmentLayout" 
     android:layout_toRightOf="@id/menuLayout" 
     android:visibility="invisible" > 

    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/howLayout" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_above="@id/bottomFragmentLayout" 
     android:layout_toRightOf="@id/menuLayout" 
     android:visibility="invisible" > 

    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/whereLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@id/bottomFragmentLayout" 
     android:layout_toRightOf="@id/menuLayout" 
     android:visibility="invisible" > 

    </RelativeLayout> 

</RelativeLayout> 
+0

我不確定這是解決我的問題? – androidneil

+0

我編輯了我的答案,現在檢查... –

+0

但是,這會如何影響事情?請解釋爲什麼這會有所作爲,尤其是在大多數情況下應用程序運行正常。 – androidneil

相關問題