Question

my program (actually not mine, I'm just trying to fix this bug) works fine on most phones, but it doesn't start on Sony Xperia P.

When I launch the program, the following message appears:

The application has stopped unexpectedly.

The app also doesn't have a launcher icon on this phone (only default icon).

The error log says:

java.lang.RuntimeException: unable to start Activity
android.view.InflateException: Binary XML file line #16: error inflating class android.view.ImageView

The error message came up when the app called:

setContentView(R.layout.menu_0_splash);

I noticed that the drawable resources are defined for the following resolutions:

1024x600 320x240 400x240 480x320 800x480 854x480

This phone is 960x540, so my best quess is that there sould be dafault resources too.

What could be the problem?

The layout file (now copy/paste-d):

<?xml version       = "1.0" 
encoding    = "utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/m0_relativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/gradient_green" >

<ImageView #this is the problematic line
    android:id="@+id/arrow_top"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="@dimen/m0_arrow_top_margintop"
    android:src="@drawable/splash_arrow_top" />

<ImageView
    android:id="@+id/arrow_bottom"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="@dimen/m0_arrow_bottom_marginbottom"
    android:src="@drawable/splash_arrow_bottom" />

<ImageView
    android:id="@+id/belt_top"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:src="@drawable/splash_belt_top" />

<ImageView
    android:id="@+id/belt_bottom"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:src="@drawable/splash_belt_bottom" />

<ImageView
    android:id="@+id/t_ad"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:adjustViewBounds="true"
    android:src="@drawable/t_ad" />

<ImageView
    android:id="@+id/title"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/t_ad"
    android:adjustViewBounds="true"
    android:src="@drawable/splash_title" />

</RelativeLayout>
Était-ce utile?

La solution 2

Finally I realized what was wrong... The phone has a special resolution (960x540), and it cannot find source images for ImageView-s and dimension file for this resolution - that's why was the app running on other phones, as they use "common" resolution.

Thanks for the help, I appreciate it with a +1

Autres conseils

Assuming that you actually copied/pasted the error from the log, then you have a typo:

java.lang.RuntimeException: unable to start Activity android.view.InflateException: Binary XML file line #16: error inflating class android.view.ImageVeiw

ImageView is spelled incorrectly in one of your layout.xml files.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top