박찬준
박찬준

Reputation: 458

ArrayIndexOutOfBoundsException when Creating LinearLayout

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?

Upvotes: 0

Views: 242

Answers (1)

VKostenc
VKostenc

Reputation: 1285

Link to the full answer.

If shortly - the issue is inside of SparseArray. Try to update the library to the latest version OR temporarily downgrade the version and watch for updates.

Upvotes: 1

Related Questions