2 years ago
#57122

ruwan liyanage
java.lang.OutOfMemoryError: Failed to allocate a 36640012 byte allocation with 16777120 free bytes and 31MB until OOM
I'm new to android and currently working on an android project. For this app, I tried to add AdMob for that. after that, there was an error like in the Title.
In previously I faced this OutOfMemory error in this same app and I was able to solve this by adding the following properties into the AndroidManifest.xml
android:hardwareAccelerated="false"
android:largeHeap="true"
After that, I added an AdMob banner ad for the application. Then was an error like this.
"Cannot fit requested classes in a single dex file (# methods: 71296 > 65536)"
That was also able to fix after adding the following properties into the build.gradle
implementation 'androidx.multidex:multidex:2.0.1'
multiDexEnabled true
But when I try to run the application, I faced the following error. When I Search, I only
able to see the following solution(add following properties into the AndroidManifest.xml
)
android:hardwareAccelerated="false"
android:largeHeap="true"
But I have already done those things as I mentioned above. So what should I need to do? I will add the stack trace here
E/art: Throwing OutOfMemoryError "Failed to allocate a 36640012 byte allocation with 16777120 free bytes and 32MB until OOM"
D/skia: --- allocation failed for scaled bitmap
D/AndroidRuntime: Shutting down VM
E/art: li.han, Prepare to dump hprof for OOM Error !
li.han, Directory [/data/misc/hprofs] could not be write !
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.handy, PID: 31817
java.lang.OutOfMemoryError: Failed to allocate a 36640012 byte allocation with 16777120 free bytes and 32MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:837)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:656)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1037)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:4056)
at android.content.res.Resources.loadDrawable(Resources.java:3929)
at android.content.res.Resources.getDrawable(Resources.java:1991)
at android.content.res.Resources.getDrawable(Resources.java:1973)
at android.content.Context.getDrawable(Context.java:409)
at androidx.core.content.ContextCompat$Api21Impl.getDrawable(ContextCompat.java:862)
at androidx.core.content.ContextCompat.getDrawable(ContextCompat.java:480)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:147)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:135)
at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:104)
at androidx.appcompat.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:63)
at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:82)
at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:69)
at androidx.appcompat.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:199)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:119)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1563)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1614)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:732)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
at com.example.handy.time.Sleep.onCreate(Sleep.java:33)
at android.app.Activity.performCreate(Activity.java:6609)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3113)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3275)
at android.app.ActivityThread.access$1000(ActivityThread.java:218)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1744)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:7007)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
android
out-of-memory
0 Answers
Your Answer