1

I working on my first Android app (published on iOS and Windows Phone before). When testing the app on a Nexu 5 eveything works fine but on a Kindle Fire the app crashes:

java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called.

This is NOT about the exception itself. I could easily solve the problem by simple using listView.addHeaderView(...) before using listView.setAdapter(...). Not a big deal, but why does the same code runs without any problem on one device but crashes on the other?

I would understand the problem if the devices would use different Android/SDK versions but this is not the case. Both devices run Android 4.2.2 with SDK Level 17...

I would understand the problem if it would be related to something close to the hardware or some vendor specific system calls, but this not the case. It is just about setting up a ListView...

So, what is the difference?

Of course I have only a limited set of test devices. How can I be sure that the app will work on all devices that are running a supported SDK Level?

EDIT: Of course one device is a phone and the other a tablet. To app uses different layouts for large screens at some places but problem also shows up in Activities/Fragments that have the same layout on both devices. Additionally no separated code for large devices is used. Using the same code and the same layout on both devices leads to a crash on the Kindle but runs on the Nexus...

Andrei Herford
  • 17,570
  • 19
  • 91
  • 225
  • One's a tablet and one's a phone. Do you have different layouts? Different code for handling larger screens? – Graham Borland Aug 20 '14 at 08:43
  • Sorry, I should have added this information in the first place: Of course the devices have different screen sizes but the effected layouts are the same on both devices. So: No different code or layouts that could influence the problem. – Andrei Herford Aug 20 '14 at 09:19
  • was it an Android 4.2 vs 4.4 issue? Now the 2013 devices are getting FireOS4 has the problem gone away? – Offbeatmammal Nov 01 '14 at 05:44

0 Answers0