1

I'm developing an android app, it's about multilingual story. In this app I can switch from a language to another. Of course this application contains several images and texts. In the arabic language some photos need to be flipped, in the following code I'm flipping 4 images:

if (i == 0) {
    rightImages[i].setImageResource(R.drawable.coverar);
}
if (i == 1) {
    rightImages[i].setImageResource(R.drawable.page1ar);
}
if (i == 4)// for the arabic flipped pages
{
    rightImages[i].setImageResource(R.drawable.page6_flipped);
    leftImages[i].setImageResource(R.drawable.page7_flipped);

}
if (i == 8)// for the arabic flipped pages
{
    rightImages[i].setImageResource(R.drawable.page14_flipped);
    leftImages[i].setImageResource(R.drawable.page15_flipped);
}

if (i != 4 && i != 8) {
    linLay[i].removeAllViews();
    linLay[i].addView(rightImages[i]);

    linLay[i].addView(leftImages[i]);
}

It's crashing and it's giving me the following error :

android.view.InflateException : Binary XML file line #26: Error inflating class <unknown>

The strange about it is that it won't crash when I change page6_flipped,page7_flipped,page14_flipped,page15_flipped to page6,page7,page14,page15.

Please note that I'm using the tablet galaxy note 10.1 2014 edition, on the other hand it isn't crashing on other tablets ( Samsung P7500 Galaxy Tab 10.1 , toshiba at7-a, samsung galaxy tab 3 10.1).

Any help please ?

hsz
  • 148,279
  • 62
  • 259
  • 315
Monzer Yaghi
  • 1,300
  • 1
  • 10
  • 21

2 Answers2

2

The images are big in size that why you are gettinh inflate exception in inflator layout in imageView,try to make your images small and before replacing set null in imageview(it will automatically call GC).and in application tag of your manifest file,add the below line:

android:Largeheap = "true"
Pankaj Arora
  • 10,224
  • 2
  • 37
  • 59
0

The error message is misleading one would think right away there is something wrong in the XML layout file. Although there may be times the cause would be that, the most obvious cause for this is when you have large images placed in only one drawable folder.

  • Well I'm using a 10" tablet so I placed the images in the folder drawable-sw700dp, and tried to place them in the folde drawable, but in all cases the application is crashing – Monzer Yaghi Jun 11 '14 at 06:49
  • Try to add the same images in all the drawable folders regardless if they are resized to a smaller resolution or not. At least, the Android OS will just pick up the images right away without having to resize them accordingly. – ask4solutions Jun 11 '14 at 06:52
  • I'm sorry I tried what you said but it's still crashing – Monzer Yaghi Jun 11 '14 at 07:05
  • If one of this resources has a high pixel resolution it would take a lot of memory causing then an inflate exception. So basically verify that the pixel resolution in your drawables images are just the minimum necessary for your layout. – ask4solutions Jun 11 '14 at 07:13
  • or refer this link - https://groups.google.com/forum/#!topic/android-developers/1mXPem3lK_E – ask4solutions Jun 11 '14 at 07:13