android binary xml exception when changing pictures
Asked Answered
R

2

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 ?

Rauscher answered 11/6, 2014 at 6:31 Comment(0)
C
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"
Cottrill answered 11/6, 2014 at 7:38 Comment(0)
I
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.

Ing answered 11/6, 2014 at 6:44 Comment(5)
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 crashingRauscher
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.Ing
I'm sorry I tried what you said but it's still crashingRauscher
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.Ing
or refer this link - groups.google.com/forum/#!topic/android-developers/1mXPem3lK_EIng

© 2022 - 2024 — McMap. All rights reserved.