Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> android.view.InflateException: Binary XML file 解決方案

android.view.InflateException: Binary XML file 解決方案

編輯:關於Android編程

android.view.InflateException: Binary XML file line #2: Error inflating class 的解決方法
java.lang.RuntimeException: Unable to start activity ComponentInfo{cn.xs8.app/cn.xs8.app.activity.news.Xs8_News_SplashActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2200)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2262)
	at android.app.ActivityThread.access$600(ActivityThread.java:148)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:137)
	at android.app.ActivityThread.main(ActivityThread.java:5145)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:802)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:569)
	at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class
	at android.view.LayoutInflater.createView(LayoutInflater.java:613)
	at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
	at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
	at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
	at android.app.Activity.setContentView(Activity.java:1943)
	at cn.xs8.app.activity.Xs8_BaseActivity.onCreate(Xs8_BaseActivity.java:74)
	at cn.xs8.app.activity.news.Xs8_News_SplashActivity.onCreate(Xs8_News_SplashActivity.java:95)
	at android.app.Activity.performCreate(Activity.java:5174)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
	... 11 more

查看了很多資料都沒解決,仔細看看就是沒有找到資源文件,看看res/下面的資源文件,全放在drawable-mdpi/目錄下,突然靈光一現,懷疑尋找的位置資源文件不存在,於是將drawable-mdpi/下的資源文件拷貝一份到drawable-ldpi/目錄下,還是報上面的錯誤,再拷貝一份到drawable-hdpi/目錄下,問題解決。

還有另外一種解決方法是在res/下建一目錄drawable/,將drawable-mdpi/下所有的資源文件都拷貝到drawable/下即可

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved