ListView内存不足异常

时间:2016-04-26 09:48:05

标签: android listview

您好我正在开发一款应用。我正在使用listview和customadapter来加载图像和文本。现在,当我滚动列表视图时,应用程序崩溃,导致内存不足异常。我不知道在这个阶段该怎么做以及如何处理这个。我发布代码段请通过它。

Near.class

package com.mateoj.multiactivitydrawer;

/**
 * Created by Akash on 3/20/2016.
 */
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CustomListNearAdapter extends ArrayAdapter<String> {

    private final Activity context;
    private final String[] itemname;
    private final Integer[] imgid;
    private final String[] itemdesc;

    public CustomListNearAdapter(Activity context, String[] itemname, Integer[] imgid,String[] itemdesc) {
        super(context, R.layout.near_layout_mylist, itemname);
        // TODO Auto-generated constructor stub

        this.context=context;
        this.itemname=itemname;
        this.imgid=imgid;
        this.itemdesc = itemdesc;
    }

    public View getView(int position,View view,ViewGroup parent) {
        LayoutInflater inflater=context.getLayoutInflater();
        View rowView=inflater.inflate(R.layout.near_layout_mylist, null,true);

        TextView txtTitle = (TextView) rowView.findViewById(R.id.item_list);
        ImageView imageView = (ImageView) rowView.findViewById(R.id.icon_list);
        TextView extratxt = (TextView) rowView.findViewById(R.id.textView1_list);

        txtTitle.setText(itemname[position]);
        imageView.setImageResource(imgid[position]);
        extratxt.setText(""+itemdesc[position]);
    return rowView;



};


}

CustomListNearAdapter

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/icon_list"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:padding="5dp" />

    <LinearLayout android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:id="@+id/item_list"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="5dp"
            android:padding="2dp"
            android:textColor="#33CC33" />
        <TextView
            android:id="@+id/textView1_list"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView"
            android:layout_marginLeft="10dp"/>
    </LinearLayout>
</LinearLayout>

NearLayout_mylist.xml

04-26 05:46:50.891    1914-1914/? I/Choreographer﹕ Skipped 276 frames!  The application may be doing too much work on its main thread.
04-26 05:46:52.883        82-82/? D/﹕ Socket deconnection
04-26 05:46:53.351      762-783/? W/ActivityManager﹕ Launch timeout has expired, giving up wake lock!
04-26 05:46:53.533    1914-1914/? I/Choreographer﹕ Skipped 158 frames!  The application may be doing too much work on its main thread.
04-26 05:46:53.693    1914-1929/? I/art﹕ Background sticky concurrent mark sweep GC freed 99(3KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 74MB/74MB, paused 7.734ms total 22.193ms
04-26 05:46:54.904        82-82/? D/﹕ Socket deconnection
04-26 05:46:56.406      762-802/? I/InputDispatcher﹕ Window 'Window{32219e00 u0 com.mateoj.multiactivitydrawer/com.mateoj.multiactivitydrawer.near}' spent 2654.5ms processing the last input event: MotionEvent(deviceId=1, source=0x00001002, action=1, flags=0x00000000, metaState=0x00000000, buttonState=0x00000000, edgeFlags=0x00000000, xPrecision=1.0, yPrecision=1.0, displayId=0, pointers=[0: (619.4, 547.7)]), policyFlags=0x62000000
04-26 05:46:56.407    1914-1914/? I/Choreographer﹕ Skipped 158 frames!  The application may be doing too much work on its main thread.
04-26 05:46:56.940        82-82/? D/﹕ Socket deconnection
04-26 05:46:57.798    1914-1914/? I/Choreographer﹕ Skipped 83 frames!  The application may be doing too much work on its main thread.
04-26 05:46:58.969        82-82/? D/﹕ Socket deconnection
04-26 05:47:00.024    1914-1914/? I/Choreographer﹕ Skipped 133 frames!  The application may be doing too much work on its main thread.
04-26 05:47:00.988        82-82/? D/﹕ Socket deconnection
04-26 05:47:02.465    1914-1914/? I/Choreographer﹕ Skipped 145 frames!  The application may be doing too much work on its main thread.
04-26 05:47:03.006        82-82/? D/﹕ Socket deconnection
04-26 05:47:04.204    1914-1914/? I/Choreographer﹕ Skipped 103 frames!  The application may be doing too much work on its main thread.
04-26 05:47:05.018        82-82/? D/﹕ Socket deconnection
04-26 05:47:05.891    1914-1914/? I/art﹕ Alloc sticky concurrent mark sweep GC freed 141(6KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 90MB/90MB, paused 9.406ms total 14.889ms
04-26 05:47:05.923    1914-1914/? I/art﹕ Clamp target GC heap from 106MB to 96MB
04-26 05:47:05.923    1914-1914/? I/art﹕ Alloc partial concurrent mark sweep GC freed 34(1328B) AllocSpace objects, 0(0B) LOS objects, 5% free, 90MB/96MB, paused 2.463ms total 31.566ms
04-26 05:47:05.946    1914-1914/? I/art﹕ Clamp target GC heap from 106MB to 96MB
04-26 05:47:05.946    1914-1914/? I/art﹕ Alloc concurrent mark sweep GC freed 10(12KB) AllocSpace objects, 0(0B) LOS objects, 5% free, 90MB/96MB, paused 5.362ms total 22.636ms
04-26 05:47:05.947    1914-1914/? I/art﹕ Forcing collection of SoftReferences for 6MB allocation
04-26 05:47:05.976    1914-1914/? I/art﹕ Clamp target GC heap from 106MB to 96MB
04-26 05:47:05.976    1914-1914/? I/art﹕ Alloc concurrent mark sweep GC freed 11(344B) AllocSpace objects, 0(0B) LOS objects, 5% free, 90MB/96MB, paused 3.079ms total 29.155ms
04-26 05:47:05.976    1914-1914/? E/art﹕ Throwing OutOfMemoryError "Failed to allocate a 7128012 byte allocation with 5880016 free bytes and 5MB until OOM"
04-26 05:47:05.985    1914-1914/? I/art﹕ Alloc sticky concurrent mark sweep GC freed 5(896B) AllocSpace objects, 0(0B) LOS objects, 5% free, 90MB/96MB, paused 1.781ms total 7.915ms
04-26 05:47:05.999    1914-1914/? I/art﹕ Clamp target GC heap from 106MB to 96MB
04-26 05:47:05.999    1914-1914/? I/art﹕ Alloc partial concurrent mark sweep GC freed 5(144B) AllocSpace objects, 0(0B) LOS objects, 5% free, 90MB/96MB, paused 848us total 11.877ms
04-26 05:47:06.021    1914-1914/? I/art﹕ Clamp target GC heap from 106MB to 96MB
04-26 05:47:06.022    1914-1914/? I/art﹕ Alloc concurrent mark sweep GC freed 4(144B) AllocSpace objects, 0(0B) LOS objects, 5% free, 90MB/96MB, paused 2.566ms total 21.970ms
04-26 05:47:06.022    1914-1914/? I/art﹕ Forcing collection of SoftReferences for 6MB allocation
04-26 05:47:06.040    1914-1914/? I/art﹕ Clamp target GC heap from 106MB to 96MB
04-26 05:47:06.040    1914-1914/? I/art﹕ Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 5% free, 90MB/96MB, paused 1.167ms total 17.432ms
04-26 05:47:06.040    1914-1914/? E/art﹕ Throwing OutOfMemoryError "Failed to allocate a 7128012 byte allocation with 5880016 free bytes and 5MB until OOM"
04-26 05:47:06.041    1914-1914/? D/skia﹕ --- allocation failed for scaled bitmap
04-26 05:47:06.043    1914-1914/? E/InputEventReceiver﹕ Exception dispatching input event.
04-26 05:47:06.043    1914-1914/? E/MessageQueue-JNI﹕ Exception in MessageQueue callback: handleReceiveCallback
04-26 05:47:06.050    1914-1914/? E/MessageQueue-JNI﹕ java.lang.OutOfMemoryError: Failed to allocate a 7128012 byte allocation with 5880016 free bytes and 5MB until OOM
            at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
            at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
            at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
            at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
            at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:988)
            at android.content.res.Resources.loadDrawableForCookie(Resources.java:2474)
            at android.content.res.Resources.loadDrawable(Resources.java:2381)
            at android.content.res.Resources.getDrawable(Resources.java:787)
            at android.content.Context.getDrawable(Context.java:403)
            at android.widget.ImageView.resolveUri(ImageView.java:747)
            at android.widget.ImageView.setImageResource(ImageView.java:398)
            at com.mateoj.multiactivitydrawer.CustomListNearAdapter.getView(CustomListNearAdapter.java:40)
            at android.widget.AbsListView.obtainView(AbsListView.java:2347)
            at android.widget.ListView.makeAndAddView(ListView.java:1864)
            at android.widget.ListView.fillDown(ListView.java:698)
            at android.widget.ListView.fillGap(ListView.java:662)
            at android.widget.AbsListView.trackMotionScroll(AbsListView.java:4991)
            at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3418)
            at android.widget.AbsListView.startScrollIfNeeded(AbsListView.java:3346)
            at android.widget.AbsListView.onTouchMove(AbsListView.java:3774)
            at android.widget.AbsListView.onTouchEvent(AbsListView.java:3632)
            at android.view.View.dispatchTouchEvent(View.java:8471)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2399)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2092)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369)
            at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719)
            at android.app.Activity.dispatchTouchEvent(Activity.java:2742)
            at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
            at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330)
            at android.view.View.dispatchPointerEvent(View.java:8666)
            at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123)
            at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
            at android.
04-26 05:47:06.052    1914-1914/? D/AndroidRuntime﹕ Shutting down VM
04-26 05:47:06.053    1914-1914/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.mateoj.multiactivitydrawer, PID: 1914
    java.lang.OutOfMemoryError: Failed to allocate a 7128012 byte allocation with 5880016 free bytes and 5MB until OOM
            at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
            at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
            at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
            at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
            at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:988)
            at android.content.res.Resources.loadDrawableForCookie(Resources.java:2474)
            at android.content.res.Resources.loadDrawable(Resources.java:2381)
            at android.content.res.Resources.getDrawable(Resources.java:787)
            at android.content.Context.getDrawable(Context.java:403)
            at android.widget.ImageView.resolveUri(ImageView.java:747)
            at android.widget.ImageView.setImageResource(ImageView.java:398)
            at com.mateoj.multiactivitydrawer.CustomListNearAdapter.getView(CustomListNearAdapter.java:40)
            at android.widget.AbsListView.obtainView(AbsListView.java:2347)
            at android.widget.ListView.makeAndAddView(ListView.java:1864)
            at android.widget.ListView.fillDown(ListView.java:698)
            at android.widget.ListView.fillGap(ListView.java:662)
            at android.widget.AbsListView.trackMotionScroll(AbsListView.java:4991)
            at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3418)
            at android.widget.AbsListView.startScrollIfNeeded(AbsListView.java:3346)
            at android.widget.AbsListView.onTouchMove(AbsListView.java:3774)
            at android.widget.AbsListView.onTouchEvent(AbsListView.java:3632)
            at android.view.View.dispatchTouchEvent(View.java:8471)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2399)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2092)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369)
            at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719)
            at android.app.Activity.dispatchTouchEvent(Activity.java:2742)
            at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
            at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330)
            at android.view.View.dispatchPointerEvent(View.java:8666)
            at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123)
            at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewR
04-26 05:47:06.059     762-1495/? W/ActivityManager﹕ Force finishing activity 1 com.mateoj.multiactivitydrawer/.near
04-26 05:47:06.088      762-783/? D/Atlas﹕ Validating map...
04-26 05:47:06.115      762-815/? I/OpenGLRenderer﹕ Initialized EGL, version 1.4
04-26 05:47:06.219      762-815/? W/EGL_emulation﹕ eglSurfaceAttrib not implemented
04-26 05:47:06.220      762-815/? W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xef0685e0, error=EGL_SUCCESS
04-26 05:47:06.818      762-783/? W/ActivityManager﹕ Activity pause timeout for ActivityRecord{12224c94 u0 com.mateoj.multiactivitydrawer/.near t129 f}
04-26 05:47:07.033        82-82/? D/﹕ Socket deconnection
04-26 05:47:08.279      762-826/? W/AudioTrack﹕ AUDIO_OUTPUT_FLAG_FAST denied by client
04-26 05:47:08.303    1914-1914/? I/Process﹕ Sending signal. PID: 1914 SIG: 9
04-26 05:47:08.355      762-815/? D/OpenGLRenderer﹕ endAllStagingAnimators on 0xf3d94480 (RippleDrawable) with handle 0xdecb0a90
04-26 05:47:08.375      762-802/? W/InputDispatcher﹕ channel '3d1b79e8 com.mateoj.multiactivitydrawer/com.mateoj.multiactivitydrawer.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
04-26 05:47:08.375      762-802/? E/InputDispatcher﹕ channel '3d1b79e8 com.mateoj.multiactivitydrawer/com.mateoj.multiactivitydrawer.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
04-26 05:47:08.376      762-802/? W/InputDispatcher﹕ channel '32219e00 com.mateoj.multiactivitydrawer/com.mateoj.multiactivitydrawer.near (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
04-26 05:47:08.376      762-802/? E/InputDispatcher﹕ channel '32219e00 com.mateoj.multiactivitydrawer/com.mateoj.multiactivitydrawer.near (server)' ~ Channel is unrecoverably broken and will be disposed!
04-26 05:47:08.383     762-1494/? I/WindowState﹕ WIN DEATH: Window{3d1b79e8 u0 com.mateoj.multiactivitydrawer/com.mateoj.multiactivitydrawer.MainActivity}
04-26 05:47:08.383     762-1494/? W/InputDispatcher﹕ Attempted to unregister already unregistered input channel '3d1b79e8 com.mateoj.multiactivitydrawer/com.mateoj.multiactivitydrawer.MainActivity (server)'
04-26 05:47:08.386     762-1495/? I/WindowState﹕ WIN DEATH: Window{32219e00 u0 com.mateoj.multiactivitydrawer/com.mateoj.multiactivitydrawer.near}
04-26 05:47:08.387     762-1495/? W/InputDispatcher﹕ Attempted to unregister already unregistered input channel '32219e00 com.mateoj.multiactivitydrawer/com.mateoj.multiactivitydrawer.near (server)'
04-26 05:47:08.399      762-778/? I/ActivityManager﹕ Process com.mateoj.multiactivitydrawer (pid 1914) has died
04-26 05:47:08.583      762-788/? V/WindowManager﹕ Adding window Window{3d6e9e8c u0 Starting com.mateoj.multiactivitydrawer} at 2 of 9 (before Window{32219e00 u0 com.mateoj.multiactivitydrawer/com.mateoj.multiactivitydrawer.near EXITING})
04-26 05:47:08.592      452-452/? I/art﹕ Background concurrent mark sweep GC freed 796(33KB) AllocSpace objects, 0(0B) LOS objects, 91% free, 93KB/1117KB, paused 5.136ms total 20.523ms
04-26 05:47:08.603    1985-1985/? I/art﹕ Late-enabling -Xcheck:jni
04-26 05:47:08.617      762-778/? I/ActivityManager﹕ Start proc 1985:com.mateoj.multiactivitydrawer/u0a79 for activity com.mateoj.multiactivitydrawer/.MainActivity
04-26 05:47:09.007    1985-2000/? W/art﹕ Suspending all threads took: 9.018ms
04-26 05:47:09.067    1985-2000/? I/art﹕ Background sticky concurrent mark sweep GC freed 1903(145KB) AllocSpace objects, 0(0B) LOS objects, 15% free, 943KB/1117KB, paused 36.521ms total 162.273ms
04-26 05:47:09.068        82-82/? D/﹕ Socket deconnection
04-26 05:47:09.239      762-788/? I/Choreographer﹕ Skipped 33 frames!  The application may be doing too much work on its main thread.
04-26 05:47:09.294    1985-2000/? I/art﹕ Background sticky concurrent mark sweep GC freed 188(37KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 7MB/7MB, paused 7.127ms total 25.781ms
04-26 05:47:09.457    1985-1985/? I/WebViewFactory﹕ Loading com.android.webview version 39 (eng.buildbot-x86) (code 399997)
04-26 05:47:09.476    1985-1985/? I/LibraryLoader﹕ Time to load native libraries: 3 ms (timestamps 115-118)
04-26 05:47:09.476    1985-1985/? I/LibraryLoader﹕ Expected native library version number "",actual native library version number ""
04-26 05:47:09.497    1985-1985/? V/WebViewChromiumFactoryProvider﹕ Binding Chromium to main looper Looper (main, tid 1) {5b08a7c}
04-26 05:47:09.498    1985-1985/? I/LibraryLoader﹕ Expected native library version number "",actual native library version number ""
04-26 05:47:09.498    1985-1985/? I/chromium﹕ [INFO:library_loader_hooks.cc(104)] Chromium logging enabled: level = 0, default verbosity = 0
04-26 05:47:09.529    1985-1985/? I/BrowserStartupController﹕ Initializing chromium process, singleProcess=true
04-26 05:47:09.531    1985-1985/? W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring
04-26 05:47:09.574    1985-1985/? W/chromium﹕ [WARNING:resource_bundle.cc(304)] locale_file_path.empty()
04-26 05:47:09.574    1985-2008/? W/AudioManagerAndroid﹕ Requires BLUETOOTH permission
04-26 05:47:09.617    1985-1985/? I/chromium﹕ [INFO:aw_browser_main_parts.cc(65)] Load from apk succesful, fd=30 off=46184 len=3037
04-26 05:47:09.618    1985-1985/? I/chromium﹕ [INFO:aw_browser_main_parts.cc(78)] Loading webviewchromium.pak from, fd:31 off:229484 len:1089587
04-26 05:47:09.673    1985-1985/? D/libEGL﹕ loaded /system/lib/egl/libEGL_emulation.so
04-26 05:47:09.675    1985-1985/? D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_emulation.so
04-26 05:47:09.712    1985-1985/? D/libEGL﹕ loaded /system/lib/egl/libGLESv2_emulation.so
04-26 05:47:09.741    1985-1985/? D/﹕ HostConnection::get() New Host Connection established 0xf3e33cb0, tid 1985
04-26 05:47:09.896    1985-1985/? W/chromium﹕ [WARNING:mailbox_synchronizer.cc(41)] MailboxSync not supported due to missing EGL image/fence support
04-26 05:47:09.934    1985-1985/? W/chromium﹕ [WARNING:data_reduction_proxy_settings.cc(331)] SPDY proxy OFF at startup
04-26 05:47:09.955    1985-1985/? W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring
04-26 05:47:09.960    1985-1985/? W/AwContents﹕ onDetachedFromWindow called when already detached. Ignoring
04-26 05:47:10.025    1985-2032/? D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
04-26 05:47:10.032    1985-1985/? D/Atlas﹕ Validating map...
04-26 05:47:10.038     762-1494/? V/WindowManager﹕ Adding window Window{26fc6245 u0 com.mateoj.multiactivitydrawer/com.mateoj.multiactivitydrawer.MainActivity} at 2 of 8 (before Window{3d6e9e8c u0 Starting com.mateoj.multiactivitydrawer})
04-26 05:47:10.123    1985-2032/? I/OpenGLRenderer﹕ Initialized EGL, version 1.4
04-26 05:47:10.124    1985-2032/? D/﹕ HostConnection::get() New Host Connection established 0xf3e38dc0, tid 2032
04-26 05:47:10.209    1985-2032/? D/OpenGLRenderer﹕ Enabling debug mo

logcat的

(?<!\\)(?=')

5 个答案:

答案 0 :(得分:0)

如果图像不存在,请将图像移动到“drawable-nodpi”文件夹中,然后创建一个。

答案 1 :(得分:0)

设置android:largeHeap =&#34; true&#34;在您的清单的应用程序标签中

答案 2 :(得分:0)

将所有图像放在每个可绘制文件夹中,如: -

drawable-hdpi,drawable-mdpi,drawable-xdpi,drawable-xxdpi和drawable-xxxdpi文件夹

或使用以下链接缩小图片尺寸: - http://compressjpeg.com/

答案 3 :(得分:0)

还有另一种解决方法......! 使用以下方法获得drawables移动图像到&#34;资产&#34;文件夹并获取BitmapDrawable。

public static Drawable getAssetImage(Context context, String filename) throws IOException {
AssetManager assets = context.getResources().getAssets();
InputStream buffer = new BufferedInputStream((assets.open("drawable/" + filename + ".png")));
Bitmap bitmap = BitmapFactory.decodeStream(buffer);
return new BitmapDrawable(context.getResources(), bitmap);

}

答案 4 :(得分:0)

您可以在AndroidMenifest.xml中编写以下代码

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:installLocation="preferExternal"
    package="com.packagename">

<application android:largeHeap="true"
android:hardwareAccelerated="false"
...
...>

....
</application>

它会增加应用程序的堆大小。