Unable to start activity ComponentInfo{com.first/com.first.Game}
生活随笔
收集整理的這篇文章主要介紹了
Unable to start activity ComponentInfo{com.first/com.first.Game}
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
原因一:
xxx的錯誤,若為R.layout.main ?那么應該是main.xml文件中的標簽 使用錯誤,最常見的而且編譯器不會提示的錯誤就是 android:name 和android:id 兩者混淆,仔細檢查main.xml的標簽是否全部正確
?
原因二:
在setContentView(view)方法之后使用了requestWindowFeature()方法,并且在此錯誤下面會提示requestFeature必須在setContentView之前使用,只需要把requestWindowFeature()方法放在setContentView(view)方法之前就可以解決.
原因三:
在onCreate()方法之外,并且不屬于任何一個方法體內直接給某控件findById(R.id.xx)所導致,需要在某方法內并且在setContentView(view)方法之前進行findById(R.id.xx)即可解決
原因四:
在setContentView(view)之前沒有對view進行實例化,只進行了聲明而直接 setContentView(view) 所導致,仔細檢查view是否setContentView(view)調用之前并在方法內進行實例化即可解決
原因五:
因為發生了空指針的錯誤異常,所以你應該檢查一下比如 Spinner 或者 list 這類的東西里面是否有值存在
總結
以上是生活随笔為你收集整理的Unable to start activity ComponentInfo{com.first/com.first.Game}的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 去掉 Android工程中让人很不爽的“
- 下一篇: onWindowFocusChanged