out of Memory
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.QrCodeGuideOne}: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.OutOfMemoryError
原因是图片“太大”,有些手机如魅族3运行无问题,但是小米3和三星就报错了。
百度一百遍都得不到答案,还是google给力
解决办法:http://stackoverflow.com/questions/20874081/android-view-inflateexception-binary-xml-file-line-8
Those stack reports are OutOfMemory exceptions, i.e. the device is out of memory.
Check in which drawable directory you are placing the background image, for 768x1280 px it should be drawable-xhdpi. Android automatically scales the image for other screen sizes, which means that if you place the image in drawable-mdpi it will be scaled to 2304x3840 for xxhdpi devices such as the Samsung 4.
Note that it is recommended to provide a bitmap resource for each supported screen size. See more about supporting multiple screen sizes here http://developer.android.com/guide/practices/screens_support.html
Other than that there is little that you can do about OutOfMemoryException other than catching the exception with a try clause on setContentView and handling it gracefully. There are some really poor Android devices out there where memory problems are frequent. You should connect your App to a better error reporting system, where you get more device data, to confirm that this is the case.
浙公网安备 33010602011771号