简体   繁体   English

应用启动后崩溃

[英]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 . 此应用程序可以正常工作,可以减少图像的数量,但可以减少图像的大小。但是我需要使用大量图像,无法安装在手机内存中,因此尝试在sd卡上安装该应用程序这个错误。 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 这是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 ?? 并且我的main.xml只包含一个imagebutton我应该发布它吗?

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

You must recycle bitmaps using bitmap.recycle(). 您必须使用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... 快乐编码...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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