0

My code works on small devices but it doesn't work on large screen devices above 5 inches.

The layout folders structure is the following:

layout-land/homeactivity.xml
layout-small-land/homeactivity.xml
layout-large-land/homeactivity.xml
layout-xlarge-land/homeactivity.xml

And the exception is:

12-17 12:26:10.811: E/AndroidRuntime(335): FATAL EXCEPTION: main 
12-17 12:26:10.811: E/AndroidRuntime(335): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pelkin.peekzoo/com.pelkin.peekzoo.Animals}: android.view.InflateException: Binary XML file line #22: Error inflating class 
12-17 12:26:10.811: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 
12-17 12:26:10.811: E/AndroidRuntime(335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
Volo
  • 28,673
  • 12
  • 97
  • 125
AndroidDevM10
  • 141
  • 2
  • 12
  • 1
    There should be more information in the exception - like *where* the `NullPointerException` occurs. – Jon Skeet Dec 17 '13 at 07:14
  • Yea you need to provide more than this for anybody to be able to help you. – Khay Dec 17 '13 at 07:14
  • u need to keep one `layout` folder as the base for any unhandled screens size – Kshitij Dec 17 '13 at 07:15
  • it is in HomeActivity class which is an Activity. – AndroidDevM10 Dec 17 '13 at 07:17
  • 12-17 12:26:10.811: E/AndroidRuntime(335): FATAL EXCEPTION: main 12-17 12:26:10.811: E/AndroidRuntime(335): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pelkin.peekzoo/com.pelkin.peekzoo.Animals}: android.view.InflateException: Binary XML file line #22: Error inflating class 12-17 12:26:10.811: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 12-17 12:26:10.811: E/AndroidRuntime(335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) – AndroidDevM10 Dec 17 '13 at 07:21

3 Answers3

2

Check all ids of every view in all xml. It should be same in all xml files.

UrMi
  • 878
  • 1
  • 6
  • 10
0

Did you have all of the images you use in all different sizes? If you're missing icons or images in the bigger sizes: drawable-xxhdpi and drawable-xhdpi, this might give you a nullpointer. Since it is trying to load an image wich doesn't exist in that size.

Black Magic
  • 2,706
  • 5
  • 35
  • 58
  • I dont think this will create the null pointer exception , since if the images are there in other drawable folders it will take the source from it – Khay Dec 17 '13 at 07:21
  • @Black Magic My image structure is as follows: drawable-land drawable-land-hdpi drawable-land-xhdpi drawable-land-mdpi drawable-land-ldpi I only put all images in ldpi and hdpi – AndroidDevM10 Dec 17 '13 at 07:22
0

the ID might be different in layout-large-land/homeactivity.xml or layout-xlarge-land/homeactivity.xml of the layout. double check your id's.

null pointer
  • 5,874
  • 4
  • 36
  • 66