NativeScript错误-java.lang.OutOfMemoryError

时间:2019-01-16 00:48:53

标签: nativescript

我正在创建NativeScript应用,并在Android模拟器上对其进行测试。不幸的是,我无法复制它,但偶尔会出现以下错误。

该应用遵循简单的“父-子”模板。从父母到孩子;回到父母,然后再回到另一个孩子-并重复多次。每个孩子都显示文本和图像。

我不确定这是Android(vs iOS)还是模拟器(vs物理设备)唯一。

An uncaught Exception occurred on "main" thread.
java.lang.OutOfMemoryError: Failed to allocate a 18925068 byte allocation with 11023464 free bytes and 10MB until OOM
    at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
    at android.graphics.Bitmap.nativeCreate(Native Method)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:831)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:808)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:739)
    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:615)
    at org.nativescript.widgets.image.Fetcher.scaleAndRotateBitmap(Fetcher.java:499)
    at org.nativescript.widgets.image.Fetcher.decodeSampledBitmapFromFile(Fetcher.java:474)
    at org.nativescript.widgets.image.Fetcher.processBitmap(Fetcher.java:263)
    at org.nativescript.widgets.image.Worker.loadImage(Worker.java:119)
    at org.nativescript.widgets.ImageView.loadImage(ImageView.java:197)
    at org.nativescript.widgets.ImageView.onAttachedToWindow(ImageView.java:58)
    at android.view.View.dispatchAttachedToWindow(View.java:14514)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
    at android.view.ViewGroup.addViewInner(ViewGroup.java:4348)
    at android.view.ViewGroup.addView(ViewGroup.java:4145)
    at android.view.ViewGroup.addView(ViewGroup.java:4086)
    at android.view.ViewGroup.addView(ViewGroup.java:4059)
    at android.view.ViewOverlay$OverlayViewGroup.add(ViewOverlay.java:190)
    at android.view.ViewGroupOverlay.add(ViewGroupOverlay.java:63)
    at android.transition.Visibility.onDisappear(Visibility.java:423)
    at android.transition.Visibility.createAnimator(Visibility.java:247)
    at android.transition.Transition.createAnimators(Transition.java:732)
    at android.transition.TransitionSet.createAnimators(TransitionSet.java:405)
    at android.transition.Transition.playTransition(Transition.java:1777)
    at android.transition.TransitionManager$MultiListener.onPreDraw(TransitionManager.java:306)
    at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2055)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
    at android.view.Choreographer.doCallbacks(Choreographer.java:670)
    at android.view.Choreographer.doFrame(Choreographer.java:606)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

1 个答案:

答案 0 :(得分:1)

decodedWidth组件上使用decodedHeight / Image。还要在largeHeap的应用程序标签上设置AndroidManifest.xml属性

<application
    android:largeHeap="true" ....