我正在尝试使用HERE Maps android SDK并在运行API 19(KitKat)的设备上进行测试。但我在启动时出现内存不足错误。它以此错误E/dalvikvm-heap: Out of memory on a 262160-byte allocation.
开头,并将异常抛出为:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.OutOfMemoryError
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:840)
at android.content.res.Resources.loadDrawable(Resources.java:2166)
at android.content.res.Resources.getDrawable(Resources.java:710)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:202)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:192)
at android.support.v7.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:421)
at android.support.v7.view.menu.ActionMenuItemView.initialize(ActionMenuItemView.java:114)
at android.support.v7.widget.ActionMenuPresenter.bindItemView(ActionMenuPresenter.java:206)
at android.support.v7.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:182)
at android.support.v7.widget.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:192)
at android.support.v7.widget.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:480)
at android.support.v7.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1138)
at android.support.v7.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:91)
at android.support.v7.widget.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:229)
at android.support.v7.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:284)
at android.support.v7.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1030)
at android.support.v7.view.menu.MenuBuilder.startDispatchingItemsChanged(MenuBuilder.java:1053)
at android.support.v7.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:460)
at android.support.v7.app.ToolbarActionBar$1.run(ToolbarActionBar.java:61)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:559)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
它似乎是一个位图问题。但我没有加载任何位图。现在新的例外是:java.lang.OutOfMemoryError
at java.io.SerializationHandleMap.resizeArrays(SerializationHandleMap.java:48)
at java.io.SerializationHandleMap.rehash(SerializationHandleMap.java:120)
at java.io.SerializationHandleMap.put(SerializationHandleMap.java:104)
at java.io.ObjectOutputStream.registerObjectWritten(ObjectOutputStream.java:493)
at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1353)
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1649)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1495)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1459)
at java.util.Hashtable.writeObject(Hashtable.java:1079)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1031)
at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1382)
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1649)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1495)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1459)
at com.here.android.mpa.internal.cd.c(ObjectSerializer.java:45)
at com.here.android.mpa.internal.cd.a(ObjectSerializer.java:22)
at com.here.android.mpa.internal.cd$1.run(ObjectSerializer.java:97)
at java.util.Timer$TimerImpl.run(Timer.java:284)
答案 0 :(得分:2)
使用此
机器人:largeHeap ="真"
答案 1 :(得分:0)
在您的应用级别levell文件中尝试此操作
dexOptions {
javaMaxHeapSize "4g"
}
并在defaultConfig
中添加此行 multiDexEnabled true