Short Version:
Is there a guaranteed minimum VM Budget Size (or at least a reasonable target)? I am exceeding it with an xml layout that is nothing but a linearlayout wrapping a single 30KB image.
Long version:
I'm getting the following error related to bitmap exceeding vm budget:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dah.rh/com.dah.rh.activities.SplashActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2649)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2674)
at android.app.ActivityThread.access$2200(ActivityThread.java:131)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1975)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4702)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:208)
at android.app.Activity.setContentView(Activity.java:1629)
at com.dah.rh.activities.SplashActivity.onCreate(SplashActivity.java:26)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2587)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.ImageView.<init>(ImageView.java:105)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 22 more
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:464)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:340)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
at android.content.res.Resources.loadDrawable(Resources.java:1714)
at android.content.res.TypedArray.getDrawable(TypedArray.java:549)
at android.widget.ImageView.<init>(ImageView.java:115)
... 26 more
The line in the stacktrace that is my code is the following:
setContentView(R.layout.splash_page);
From here, Android attempts to inflate the resource splash_page.xml listed below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/logo"/>
</LinearLayout>
The image "logo.png" is a 240x138px png sizing in at 30KB. It seems strange to me that this would exceed the budget whereas other pages where I have loaded 6 images totaling over 35KB total have not exceeded the budget. It seems like the only thing I can do is to shrink the image, but I have no idea how small to make it.
The minimum budget, so to speak, is 16MB, insofar as the smallest maximum heap size for an Android application is 16MB. You are not exceeding it with a single PNG file of the size you describe.
Related
I have an Android app which has a minimum SDK at 2.1 and I am getting the following stack trace in the developer console:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.versions.MyPhone}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2705)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2721)
at android.app.ActivityThread.access$2300(ActivityThread.java:132)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4669)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
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:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:203)
at android.app.Activity.setContentView(Activity.java:1656)
at com.versions.MyPhone.onCreate(MyPhone.java:49)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.LinearLayout.<init>(LinearLayout.java:115)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 21 more
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
at android.content.res.Resources.loadDrawable(Resources.java:1709)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1885)
at android.view.View.<init>(View.java:1834)
at android.view.ViewGroup.<init>(ViewGroup.java:285)
The error doesn't happen in the newer devices with an updated Os.
Please help me resolve the issue or point me in the right direction.
Based on the java.lang.OutOfMemoryError: bitmap size exceeds VM budget message in the stack trace, it appears that one of the images in the view being opened in your onCreate() is too large.
Here's a page with some guidance. The main idea is to load a scaled down version of the image. I've found it best to also scale down (resolution, color-depth, etc.) the actual image file to maximize loading speed.
I put an application on Play Store and I received a Crash report that I'm having an hard time to reproduce.
It comes from a V858 (hwu8160) device running Android 2.2. The exception it raised is the following:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mariosangiorgio.FutsalCoach/com.mariosangiorgio.FutsalCoach.FutsalCoachActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201)
at android.app.Activity.setContentView(Activity.java:1647)
at com.mariosangiorgio.FutsalCoach.FutsalCoachActivity.onCreate(FutsalCoachActivity.java:89)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.TextView.<init>(TextView.java:352)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 22 more
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
at android.widget.TextView.<init>(TextView.java:677)
... 26 more
I setup an emulator running Android 2.2 but I cannot reproduce the issue. Do you have any suggestion about what I should to in order to find the cause of the error and fix it?
This is what I have in the activity layout file at line 10:
<TextView
android:id="#+id/match_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="#string/default_time"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="#dimen/bigClockFontSize"
android:singleLine="true" />
It seems that for some reason the device is not loading the #dimen/bigClockFontSize value.
I managed to trigger the error in the emulator by removing the value from res/values/dimens.xml.
The device presenting the error is using the italian locale and the device has a small screen.
I have the following resources files:
values/dimens.xml
values/strings.xml
values/styles.xml
values-it/strings.xml
values-normal-hdpi/dimens.xml
values-normal-xxhdpi/dimens.xml
I assume that the device should resolve the values/dimes.xml file. Does it do that?
Try these links:
Android View inflateException
android.view.InflateException: Binary XML file line #30: Error inflating class <unknown>
android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>
Hope you find your answer from here.
We experience Out Of Memory Error when running our application on Intel HAXM emulator. At the same time application is stable when we run it in usual android ARM Emulator. The error log is:
12-03 12:13:20.258: ERROR/AndroidRuntime(3048): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{coza.sintez.xplat/coza.sintez.xplat.activity.fields.NumberFieldActivity}: android.view.InflateException: Binary XML file line #4: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #4: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:518)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:682)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
at android.app.Activity.setContentView(Activity.java:1657)
at coza.sintez.xplat.activity.fields.NumberFieldActivity.onCreate(NumberFieldActivity.java:51)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at android.view.LayoutInflater.createView(LayoutInflater.java:505)
... 26 more
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
at android.content.res.Resources.loadDrawable(Resources.java:1709)
at android.content.res.Resources.getDrawable(Resources.java:581)
at android.graphics.drawable.InsetDrawable.inflate(InsetDrawable.java:103)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:172)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
at android.content.res.Resources.loadDrawable(Resources.java:1694)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1951)
at android.widget.TextView.<init>(TextView.java:350)
at android.widget.Button.<init>(Button.java:108)
at android.widget.Button.<init>(Button.java:104)
... 29 more
12-03 12:13:20.318: WARN/ActivityManager(851): Force finishing activity coza.sintez.xplat/.activity.fields.NumberFieldActivity
All activities are optimized and do not use large bitmaps. DDMS memory profiler do not show any memory leaks as well.
Also we noticed that if we run application at the first time, it can perform some task(for example navigate to some activity). But if we completely re-install application and run again, it fails doing the same task. Seems like Intel Emulator is not freeing up memory correctly. Has anybody experienced the same?
Don't be surprised by having Out of memory error in AVD and not with the other.
Each AVD has his own configuration for maximum Heap memory, and the reason why you are hitting it with Intel emulator is just that the default maximum heap memory made available for your app is smaller than the one provided by ARM emulator.
You can check the heap memory available to your app using:
Log.d(TAG,"Heap size: " + Runtime.getRuntime().maxMemory());
Although you can control the heap size in the emulator and make it run in both, you can't do it for the user device.
So, if you are trageting devices with smaller heap size, you need to review your code and ensure that it fits in that amount of memory. Otherwise, you can specify the minimum amount of heap required for your application in AndroidManifest.xml and it will only shows suitable devices.
Regards.
by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget at
clearly bitmap size exceed VM budget
and when you second time run your app still bitmap factory hold that image in factory which is actually in VM budget.
remove bitmap onDestroy Activity
In your code error java.lang.OutOfMemoryError: Bitmap Size Exceeds VM Budget is appeared
check this thread for more solution.
I added the admob adview from xml like this;
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_above="#id/footerContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="..."
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR" />
First; there seems to be no problem. But when i change the orientation of the screen a couple of times quickly; the app crashed. I have these errors;
1- bitmap size exceeds VM budget
java.lang.OutOfMemoryError: bitmap size exceeds VM budget at
android.graphics.Bitmap.nativeCreate(Native Method) at
android.graphics.Bitmap.createBitmap(Bitmap.java:477) at
android.graphics.Bitmap.createBitmap(Bitmap.java:444) at
android.graphics.Bitmap.createScaledBitmap(Bitmap.java:349) at
android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:498) at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:473) at
android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
at
android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
at android.content.res.Resources.loadDrawable(Resources.java:1785) at
android.content.res.TypedArray.getDrawable(TypedArray.java:601) at
android.widget.ImageView.(ImageView.java:118) at
android.widget.ImageButton.(ImageButton.java:85) at
android.widget.ImageButton.(ImageButton.java:81) at
java.lang.reflect.Constructor.constructNative(Native Method) at
java.lang.reflect...
2- Binary XML file line #16: Error inflating class
android.view.InflateException: Binary XML file line #16: Error
inflating class at
android.view.LayoutInflater.createView(LayoutInflater.java:518) at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) at
android.view.LayoutInflater.inflate(LayoutInflater.java:408) at
android.view.LayoutInflater.inflate(LayoutInflater.java:320) at
android.view.LayoutInflater.inflate(LayoutInflater.java:276) at
com.X.ui.FooterFragment.onCreateView(FooterFragment.java:21) at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:846)
at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
at
android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:...
3- Unable to start activity
ComponentInfo{com.x/com.x.ui.HomeActivity}:
android.view.InflateException: Binary XML file line #13: Error
inflating class
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.X/com.X.ui.HomeActivity}:
android.view.InflateException: Binary XML file line #13: Error
inflating class at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
at
android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2953)
at android.app.ActivityThread.access$1600(ActivityThread.java:123) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:943) at
android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:130) at
android.app.ActivityThread.main(ActivityThread.java:3835) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:507) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(Zygo.
I tried adding it programmatically as described here, but nothing changed... Any ideas?
For 1, what SDK version are you using, and what device are you running it on? This may be an emulator specific issue.
2 and 3 are likely due to not linking the AdMob library correctly. See Error inflating class com.google.ads.AdView.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.falling.inairproandmark/com.falling.inairproandmark.Q9Popup}: android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:219)
at android.app.Activity.setContentView(Activity.java:1647)
at com.falling.inairproandmark.Q9Popup.onCreate(Q9Popup.java:36)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.Button.<init>(Button.java:65)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 22 more
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
at android.content.res.Resources.loadDrawable(Resources.java:1709)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1885)
at android.widget.TextView.<init>(TextView.java:352)
at android.widget.Button.<init>(Button.java:69)
... 26 more
==
here's my xml layout:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:background="#drawable/q9popup" android:id="#+id/qnine"
android:layout_width="fill_parent" android:layout_height="fill_parent">
</Button>
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="**********"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
</AbsoluteLayout>
I don't understand why I keep getting this error :S
Please help.
Thanks
Android cannot allocate the memory for the Button. Pre-Honeycomb allocates the memory for a bitmap natively, outside the Dalvik VM, using malloc and has to rely on Java finalizers to free that memory again. Unless you call Bitmap.recycle that is.
See http://www.youtube.com/watch?v=_CruQY55HOk&feature=player_detailpage#t=650s for some info on allocation of Bitmaps.
So you have to figure out why external allocation is so high in your app. Maybe AdMob is the cause. Make sure to invoke AdView.destroy in your activity's onDestroy.