问题描述:

Here is my log output. I need your help determining where to begin to solve the issue:

If I execute the app in a device with version 4.4.2, no exception is thrown, but executing the app on a device with lower version, the app crashes..

12-05 11:34:50.716: E/AndroidRuntime(327): FATAL EXCEPTION: main

12-05 11:34:50.716: E/AndroidRuntime(327): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.solinpromex.casajuventudtrescantos/com.solinpromex.casajuventudtrescantos.MainActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class <unknown>

12-05 11:34:50.716: E/AndroidRuntime(327): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.app.ActivityThread.access$1500(ActivityThread.java:117)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.os.Handler.dispatchMessage(Handler.java:99)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.os.Looper.loop(Looper.java:123)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.app.ActivityThread.main(ActivityThread.java:3683)

12-05 11:34:50.716: E/AndroidRuntime(327): at java.lang.reflect.Method.invokeNative(Native Method)

12-05 11:34:50.716: E/AndroidRuntime(327): at java.lang.reflect.Method.invoke(Method.java:507)

12-05 11:34:50.716: E/AndroidRuntime(327): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

12-05 11:34:50.716: E/AndroidRuntime(327): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

12-05 11:34:50.716: E/AndroidRuntime(327): at dalvik.system.NativeStart.main(Native Method)

12-05 11:34:50.716: E/AndroidRuntime(327): Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class <unknown>

12-05 11:34:50.716: E/AndroidRuntime(327): at android.view.LayoutInflater.createView(LayoutInflater.java:518)

12-05 11:34:50.716: E/AndroidRuntime(327): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)

12-05 11:34:50.716: E/AndroidRuntime(327): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.app.Activity.setContentView(Activity.java:1657)

12-05 11:34:50.716: E/AndroidRuntime(327): at com.solinpromex.casajuventudtrescantos.MainActivity.onCreate(MainActivity.java:28)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)

12-05 11:34:50.716: E/AndroidRuntime(327): ... 11 more

12-05 11:34:50.716: E/AndroidRuntime(327): Caused by: java.lang.reflect.InvocationTargetException

12-05 11:34:50.716: E/AndroidRuntime(327): at java.lang.reflect.Constructor.constructNative(Native Method)

12-05 11:34:50.716: E/AndroidRuntime(327): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.view.LayoutInflater.createView(LayoutInflater.java:505)

12-05 11:34:50.716: E/AndroidRuntime(327): ... 22 more

12-05 11:34:50.716: E/AndroidRuntime(327): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

12-05 11:34:50.716: E/AndroidRuntime(327): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.content.res.Resources.loadDrawable(Resources.java:1709)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.widget.ImageView.<init>(ImageView.java:118)

12-05 11:34:50.716: E/AndroidRuntime(327): at android.widget.ImageView.<init>(ImageView.java:108)

12-05 11:34:50.716: E/AndroidRuntime(327): ... 25 more

12-05 11:34:50.726: W/ActivityManager(60): Force finishing

网友答案:

The reason is clear:

12-05 11:34:50.716: E/AndroidRuntime(327): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

Solution: try to use the drawable with smaller resolution.

网友答案:

You have run out of memory which caused a bunch of issues (cannot inflate the activity xml which causes the activity to not start since you get an exception in the onCreate method that is not handled)

12-05 11:34:50.716: E/AndroidRuntime(327): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.content.res.Resources.loadDrawable(Resources.java:1709)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)

to fix it try loading a smaller size bitmap for in your imageview for lesser devices (pre 4.4.2)

相关阅读:
Top