Android中图片资源文件找不到的问题

最近每天被Google坑,整个人也是不太好。。。

你们遇到过这样恶心的Log吗?这个.9的资源文件明明就在那里,却说不在。仔细研究,发现竟然是downsampling的时候出了问题。

 

放在高dpi目录中的图片资源文件,在低dpi手机上使用的时候,会自动进行缩小。如果你放在高dpi目录(比如drawable-xxhdpi)中的图片尺寸太小,那么大小就可能会被缩小为0,出现了这个问题。

 

解决方案:很简单,把图片改大一点。。。。。

 

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jupaidaren.android/com.jupaidaren.android.PhotoActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2003)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2028)
	at android.app.ActivityThread.access$600(ActivityThread.java:130)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1156)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:4503)
	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:811)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:578)
	at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
	at android.view.LayoutInflater.createView(LayoutInflater.java:606)
	at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
	at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
	at android.view.LayoutInflater.parseInclude(LayoutInflater.java:800)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:729)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
	at com.jupaidaren.android.fragment.PhotoFragment.onCreateView(PhotoFragment.java:112)
	at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:953)
	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
	at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
	at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
	at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
	at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1133)
	at android.app.Activity.performStart(Activity.java:4482)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1976)
	... 11 more
Caused by: java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Constructor.constructNative(Native Method)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
	at android.view.LayoutInflater.createView(LayoutInflater.java:586)
	... 28 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi/bg_input.9.png from drawable resource ID #0x7f020004
	at android.content.res.Resources.loadDrawable(Resources.java:1942)
	at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
	at android.view.View.<init>(View.java:2785)
	at android.view.ViewGroup.<init>(ViewGroup.java:388)
	at android.widget.LinearLayout.<init>(LinearLayout.java:174)
	at android.widget.LinearLayout.<init>(LinearLayout.java:170)
	... 31 more
Caused by: java.lang.IllegalArgumentException: width and height must be > 0
	at android.graphics.Bitmap.createBitmap(Bitmap.java:603)
	at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
	at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
	at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
	at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
	at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
	at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
	at android.content.res.Resources.loadDrawable(Resources.java:1937)
	... 36 more

你可能感兴趣的:(Android)