<bitmap> requires a valid SRC attribute

Source: Internet
Author: User

E/androidruntime (1601): FATAL Exception:main
E/androidruntime (1601): Process:com.android.camera2, pid:1601
E/androidruntime (1601): Android.content.res.resources$notfoundexception:file res/drawable/ic_capture_ Video.xml from drawable resource ID #0x7f02004b
E/androidruntime (1601): at Android.content.res.Resources.loadDrawableForCookie (resources.java:2428)
E/androidruntime (1601): at Android.content.res.Resources.loadDrawable (resources.java:2330)
E/androidruntime (1601): at Android.content.res.Resources.getDrawable (resources.java:758)
E/androidruntime (1601): at Android.content.res.Resources.getDrawable (resources.java:724)
E/androidruntime (1601): at Com.android.camera.ui.BottomBar.setShutterButtonIcon (bottombar.java:432)
E/androidruntime (1601): at Com.android.camera.app.CameraAppUI.setBottomBarShutterIcon (cameraappui.java:1706)
E/androidruntime (1601): at Com.android.camera.app.CameraAppUI.resetBottomControls (cameraappui.java:1647)
E/androidruntime (1601): at com.android.camera.CameraActivity.onModeSelected (cameraactivity.java:2127)
E/androidruntime (1601): at com.android.camera.app.CameraAppUI.onModeSelected (cameraappui.java:1414)
E/androidruntime (1601): at com.android.camera.ui.ModeListView.onModeSelected (modelistview.java:1238)
E/androidruntime (1601): at com.android.camera.ui.modelistview.access$4600 (modelistview.java:64)
E/androidruntime (1601): at Com.android.camera.ui.modelistview$peepholeanimationeffect$8$1.run (ModeListView.java : 2120)
E/androidruntime (1601): at Android.os.Handler.handleCallback (handler.java:739)
E/androidruntime (1601): at Android.os.Handler.dispatchMessage (handler.java:95)
E/androidruntime (1601): at Android.os.Looper.loop (looper.java:135)
E/androidruntime (1601): at Android.app.ActivityThread.main (activitythread.java:5221)
E/androidruntime (1601): at Java.lang.reflect.Method.invoke (Native Method)
E/androidruntime (1601): at Java.lang.reflect.Method.invoke (method.java:372)
E/androidruntime (1601): at Com.android.internal.os.zygoteinit$methodandargscaller.run (ZygoteInit.java:899)
E/androidruntime (1601): at Com.android.internal.os.ZygoteInit.main (zygoteinit.java:694)
E/androidruntime (1601): caused by:org.xmlpull.v1.XmlPullParserException:Binary XML file line #25: <bitmap> R Equires a valid src attribute
E/androidruntime (1601): at Android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray ( bitmapdrawable.java:744)
E/androidruntime (1601): at Android.graphics.drawable.BitmapDrawable.inflate (bitmapdrawable.java:709)
E/androidruntime (1601): at Android.graphics.drawable.Drawable.createFromXmlInner (drawable.java:1095)
E/androidruntime (1601): at Android.graphics.drawable.StateListDrawable.inflate (statelistdrawable.java:185)
E/androidruntime (1601): at Android.graphics.drawable.Drawable.createFromXmlInner (drawable.java:1095)
E/androidruntime (1601): at Android.graphics.drawable.Drawable.createFromXml (drawable.java:1017)
E/androidruntime (1601): at Android.content.res.Resources.loadDrawableForCookie (resources.java:2418)

E/androidruntime (1601): ... More

The harvest brought by the above exception:

This is the notfoundexception exception thrown by the code of the Andoird built-in System app camera

The direct reason is that the invalid bitmap object referenced in an XML file under Drawable causes the resource to not be found.

Fuse: The owner of the application in the encoding of the name of the image and the drawable under the names of the XML file. Under normal circumstances this is not a problem, Android can differentiate between XML and PNG files, the key is that in some cases the problem comes.

Things in the following: Our company before the products are hdpi products, and the recent project is small screen ldpi, in the configuration board, directly from the original board fork over a board, and Product_aapt_config is still hdpi, This leads to the compiled apk, the resources are only hdpi. When the application load ldpi resources at run time, can not find, so find the attachment high-resolution resources, which just put the drawable directory Ic_capture_video.xml as a ic_captrue_video.png (all drawable/ Ic_capture_video) So it references an invalid bitmap source.


Suggestion to fix this bug:

1,camera app avoids the same name as XML and PNG to prevent accidents;

2,board configuration facts are realistic, according to dip configuration Product_aapt_config


Summary: This is a problem with multiple non-canonical concurrency.


1, DPIwith screen resolution/formula for calculating physical dimensions

public static int dip2px (context context, float Dipvalue) {
Final Float scale = context.getresources (). Getdisplaymetrics (). density;
return (int) (Dipvalue * scale + 0.5f);
}  
 
public static int Px2dip (context context, float Pxvalue) {
Final Float scale = context.getresources (). Getdisplaymetrics (). density;
return (int) (Pxvalue/scale + 0.5f);

2 product_aapt_config = xxxxmatching rules for resource selection?
In principle, priority is given to resources that correspond to device dpi, followed by high DPI resources with lower dpi, high DPI resources at higher dpi, and finally nodpi resources, whereby the priority of different DPI resources varies depending on the dpi of the device (ignoring MDPI &AMP;HDPI):
Device dpi Priority order (high-to-low)
tvdpi tvdpi>hdpi>xhdpi>xxhdpi>mdpi>default>ldpi>nodpi
hdpi hdpi>tvdpi>xhdpi>xxhdpi>>mdpi>default>ldpi>nodpi
xhdpi xhdpi>xxhdpi>hdpi>tvdpi>mdpi>default>ldpi>nodpi
xxhdpi xxhdpi>xhdpi>hdpi>tvdpi>mdpi>default>ldpi>nodpi







<bitmap> requires a valid SRC attribute

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.