0

Hello? I am debugging some issue related with Android widget.

My app is using two thread provided by Glide library to make original widget image file and thumbnail widget image file.

When Making a widget image file, My app create some layout like a LinearLayout and draw it in a bitmap (ex) layout.draw(Canvas(bitmap))) and save bitmap into a file.

It works fine in almost time, but some issues are reported like below sometimes.

java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
  at android.util.ContainerHelpers.binarySearch(ContainerHelpers.java:28)
  at android.util.SparseArray.get(SparseArray.java:120)
  at android.util.SparseArray.get(SparseArray.java:111)
  at android.view.ViewConfiguration.get(ViewConfiguration.java:494)
  at android.view.View.<init>(View.java:5432)
  at android.view.View.<init>(View.java:5624)
  at android.view.ViewGroup.<init>(ViewGroup.java:687)
  at android.widget.LinearLayout.<init>(LinearLayout.java:254)
  at android.widget.LinearLayout.<init>(LinearLayout.java:250)
  at android.widget.LinearLayout.<init>(LinearLayout.java:246)
  at android.widget.LinearLayout.<init>(LinearLayout.java:242)

This Exception is thrown when I just make a LinearLayout like this LinearLayout(context).apply { orientation = LinearLayout.VERTICAL }

I suspect some Concurrency. Is there any problem with creating LinearLayout in Multithread?

박찬준
  • 346
  • 1
  • 7
  • You can create view only in main thread. please attach your code, if you are use list for create layout you must check it size. – aref behboodi Sep 06 '21 at 04:03
  • @arefbehboodi I'm not refreshing ui in worker thread. I'm just making LinearLayout and adding some child view to the LinearLayout and drawing it into bitmap and saving it. The code I am editing is my company's code so I can't not attach it in this question. – 박찬준 Sep 06 '21 at 04:33

0 Answers0