Android-android 奇怪的问题
问题具体log,在手机上面测试不会出问题,但是在模拟器上面会导致应用崩溃,xml文件没有问题,涉及的图片大小不超过30kb,请高手详细分析解释下....
10-10 02:32:28.649: E/AndroidRuntime(375): FATAL EXCEPTION: main
10-10 02:32:28.649: E/AndroidRuntime(375): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hkt.android.ehealth/com.hkt.android.ehealth.activities.MyGoalDetailActivity}: android.view.InflateException: Binary XML file line #21: Error inflating class <unknown>
10-10 02:32:28.649: E/AndroidRuntime(375): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.os.Handler.dispatchMessage(Handler.java:99)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.os.Looper.loop(Looper.java:123)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-10 02:32:28.649: E/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method)
10-10 02:32:28.649: E/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:507)
10-10 02:32:28.649: E/AndroidRuntime(375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-10 02:32:28.649: E/AndroidRuntime(375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-10 02:32:28.649: E/AndroidRuntime(375): at dalvik.system.NativeStart.main(Native Method)
10-10 02:32:28.649: E/AndroidRuntime(375): Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class <unknown>
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
10-10 02:32:28.649: E/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-10 02:32:28.649: E/AndroidRuntime(375): at com.hkt.android.ehealth.activities.TitleBarActivity.setContentView(TitleBarActivity.java:170)
10-10 02:32:28.649: E/AndroidRuntime(375): at com.hkt.android.ehealth.activities.MyGoalDetailActivity.onCreate(MyGoalDetailActivity.java:63)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-10 02:32:28.649: E/AndroidRuntime(375): ... 11 more
10-10 02:32:28.649: E/AndroidRuntime(375): Caused by: java.lang.reflect.InvocationTargetException
10-10 02:32:28.649: E/AndroidRuntime(375): at java.lang.reflect.Constructor.constructNative(Native Method)
10-10 02:32:28.649: E/AndroidRuntime(375): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
10-10 02:32:28.649: E/AndroidRuntime(375): ... 23 more
10-10 02:32:28.649: E/AndroidRuntime(375): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
10-10 02:32:28.649: E/AndroidRuntime(375): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.content.res.Resources.loadDrawable(Resources.java:1709)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.View.<init>(View.java:1951)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.View.<init>(View.java:1899)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.view.ViewGroup.<init>(ViewGroup.java:286)
10-10 02:32:28.649: E/AndroidRuntime(375): at android.widget.LinearLayout.<init>(LinearLayout.java:120)
10-10 02:32:28.649: E/AndroidRuntime(375): ... 26 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个错误好象出现的情况比较多,总结一下的话,差不多都是因为使用 xml 布局的时候没有找到布局文件中要使用的类,或者引用第三方的组件时没有导入到 apk,以及使用自定义的类与当前包在编译的顺序之下。
这个问题应该不仅仅在虚拟机上,只能说明你测试用的手机配置较好。
OOM,上面显示xml的问题只是因为在打开一个activity,展开一个布局的时候需要申请资源,但是系统没有空闲资源可用,所以xml打不开,程序也就出现崩溃的现象。
无论是图片,对象,最后都是有对象无法被系统释放造成的。此时最好用MAT等内存分析工具去分析下内存中一直不能被释放的资源。