Nativescript: Android drawables and ListView cause java.lang.IllegalArgumentException: Problem decoding into existing bitmap

Created on 4 Jun 2018  路  6Comments  路  Source: NativeScript/NativeScript

Using drawable resource images with ListView (RadListView) and scrolling is causing the application to crash with the error below.

The case is reproducible when the application has images provided in only one drawable folder with images (no images for all screen densities). E.g use this demo application where the images are available only in drawable-hdpi folder - the other drawable folrders are empty.

Result when scrolling the list:

Successfully synced application org.nativescript.drawablesContentListing on device ZX1G424QFC.
ActivityManager: Start proc 12053:org.nativescript.drawablesContentListing/u0a1283 for activity org.nativescript.drawablesContentListing/com.tns.NativeScriptActivity
JS: Binding: Binding error while setting property src of Image(13)@file:///app/main-page.xml:12:21;: Error: java.lang.IllegalArgumentException: Problem decoding into existing bitmap
JS:     org.nativescript.widgets.image.Fetcher.decodeSampledBitmapFromResource(Fetcher.java:389)
JS:     org.nativescript.widgets.image.Fetcher.processBitmap(Fetcher.java:268)
JS:     org.nativescript.widgets.image.Worker.loadImage(Worker.java:119)
JS:     org.nativescript.widgets.ImageView.loadImage(ImageView.java:197)
JS:     org.nativescript.widgets.ImageView.setUri(ImageView.java:185)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1100)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:982)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:969)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:953)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:945)
JS:     com.tns.gen.android.widget.BaseAdapter_view_195_32_ListViewAdapter.getView(BaseAdapter_view_195_32_ListViewAdapter.java:52)
JS:     android.widget...
JS: Binding: Binding error while setting property src of Image(17)@file:///app/main-page.xml:12:21;: Error: java.lang.IllegalArgumentException: Problem decoding into existing bitmap
JS:     org.nativescript.widgets.image.Fetcher.decodeSampledBitmapFromResource(Fetcher.java:389)
JS:     org.nativescript.widgets.image.Fetcher.processBitmap(Fetcher.java:268)
JS:     org.nativescript.widgets.image.Worker.loadImage(Worker.java:119)
JS:     org.nativescript.widgets.ImageView.loadImage(ImageView.java:197)
JS:     org.nativescript.widgets.ImageView.setUri(ImageView.java:185)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1100)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:982)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:969)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:953)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:945)
JS:     com.tns.gen.android.widget.BaseAdapter_view_195_32_ListViewAdapter.getView(BaseAdapter_view_195_32_ListViewAdapter.java:52)
JS:     android.widget...
System.err: java.lang.IllegalArgumentException: Problem decoding into existing bitmap
System.err:     at org.nativescript.widgets.image.Fetcher.decodeSampledBitmapFromResource(Fetcher.java:389)
System.err:     at org.nativescript.widgets.image.Fetcher.processBitmap(Fetcher.java:268)
System.err:     at org.nativescript.widgets.image.Worker.loadImage(Worker.java:119)
System.err:     at org.nativescript.widgets.ImageView.loadImage(ImageView.java:197)
System.err:     at org.nativescript.widgets.ImageView.onAttachedToWindow(ImageView.java:58)
System.err:     at android.view.View.dispatchAttachedToWindow(View.java:15509)
System.err:     at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
System.err:     at android.view.ViewGroup.addViewInner(ViewGroup.java:4456)
System.err:     at android.view.ViewGroup.addViewInLayout(ViewGroup.java:4393)
System.err:     at android.widget.ListView.setupChild(ListView.java:2052)
System.err:     at android.widget.ListView.makeAndAddView(ListView.java:1973)
System.err:     at android.widget.ListView.fillDown(ListView.java:704)
System.err:     at android.widget.ListView.fillGap(ListView.java:668)
System.err:     at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5186)
System.err:     at android.widget.ListView.trackMotionScroll(ListView.java:1889)
System.err:     at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4734)
System.err:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
System.err:     at android.view.Choreographer.doCallbacks(Choreographer.java:686)
System.err:     at android.view.Choreographer.doFrame(Choreographer.java:618)
System.err:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
System.err:     at android.os.Handler.handleCallback(Handler.java:751)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
System.err:     at android.os.Looper.loop(Looper.java:154)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6119)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
ActivityManager: Process org.nativescript.drawablesContentListing (pid 12053) has died
ActivityManager: cleanUpApplicationRecord -- 12053

Workaround:

  • Provide the images in all Android drawable folders


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

backlog bug android high

Most helpful comment

@triniwiz I believe we fixed this on a fork last year? Perhaps we could go forth with the fix in this repo and get it published.

All 6 comments

Reproducible with [email protected]

Reproducible with [email protected]

I face the same problem without using the ListView at all:

java.lang.IllegalArgumentException: 
  at org.nativescript.widgets.image.Fetcher.decodeSampledBitmapFromResource (Fetcher.java:389)
  at org.nativescript.widgets.image.Fetcher.processBitmap (Fetcher.java:268)
  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:21307)
  at android.view.ViewGroup.dispatchAttachedToWindow (ViewGroup.java:4246)

I have, however, images (.jpg), which are sourced from the app folder (platforms\android\app\src\main\assets\app\images\) and not the src\main\drawables. It seems it occurs occasionally and so far I was not able to replicate it locally. Nevertheless, the app uses many images, so there might be a problem in one of them. Any ideas on how to proceed with this?

Some environment details: It fails mainly on Android 10 (7 out of 8 reports) on Galaxy Note10+ and Galaxy S10+. The only different device is Galaxy S8 with Android 9.

We've recently been getting this exact issue as well, which makes the entire app crash. Has there been a workaround discovered or any progress on a patch?

@triniwiz I believe we fixed this on a fork last year? Perhaps we could go forth with the fix in this repo and get it published.

Hello,

Any update on this one?

Was this page helpful?
0 / 5 - 0 ratings