简体   繁体   中英

App crashes after launch

This app am working with works fine with less no of images to be specific less size of images.But i need to use a lot of images,and was unable to install in phone internal memory I tried installing the app on my sd card and got this error . Can not understand why. How to resolve this

This is what the log cat says

E/dalvikvm-heap(17405): Out of memory on a 3234424-byte allocation.
E/AndroidRuntime(17405): FATAL EXCEPTION: main
E/AndroidRuntime(17405): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mystictreegames.pagecurl/com.mystictreegames.pagecurl.StandaloneExample}: android.view.InflateException: Binary XML file line #6: Error inflating class com.mystictreegames.pagecurl.PageCurlView
E/AndroidRuntime(17405):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343)
E/AndroidRuntime(17405):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
E/AndroidRuntime(17405):    at android.app.ActivityThread.access$600(ActivityThread.java:162)
E/AndroidRuntime(17405):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
E/AndroidRuntime(17405):    at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(17405):    at android.os.Looper.loop(Looper.java:194)
E/AndroidRuntime(17405):    at android.app.ActivityThread.main(ActivityThread.java:5371)
E/AndroidRuntime(17405):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(17405):    at java.lang.reflect.Method.invoke(Method.java:525)
E/AndroidRuntime(17405):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
E/AndroidRuntime(17405):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
E/AndroidRuntime(17405):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(17405): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.mystictreegames.pagecurl.PageCurlView
E/AndroidRuntime(17405):    at android.view.LayoutInflater.createView(LayoutInflater.java:613)

and my memory card is almost empty.

This is standalone_example.xml

<?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">
    <com.mystictreegames.pagecurl.PageCurlView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/dcgpagecurlPageCurlView1"
        android:background="@drawable/background">
    </com.mystictreegames.pagecurl.PageCurlView>
</LinearLayout>

and my main.xml contains nothing but an imagebutton should I post that also ??

确保将PageCurlView放置在com.mystictreegames.pagecurl

You must recycle bitmaps using bitmap.recycle(). If you don't recycle your bitmaps you risk an out of memory exception.

so use

bitmap.recycle();
bitmap = null;

This will assure the bitmap is garbage collected.

Or else if this is memory issue then you can use

 android:largeHeap="true"

inside your manifest application tag. This will allow you to load more bitmap... Hope this will help you. Happy Coding...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM