Android活动无法在某些设备上启动(错误充气类)

时间:2012-12-04 10:34:28

标签: android resolution sony runtimeexception inflate-exception

我的程序(实际上不是我的,我只是想解决这个问题)在大多数手机上运行正常,但它并不是从Sony Xperia P开始的。

启动程序时,将显示以下消息:

应用程序意外停止。

该应用在此手机上也没有启动器图标(仅限默认图标)。

错误日志显示:

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

应用程序调用时出现错误消息:

setContentView(R.layout.menu_0_splash);

我注意到可绘制资源是针对以下分辨率定义的:

1024x600的 320×240 400X240 分辨率480x320 800X480 854×480

这款手机的电话是960x540,所以我最好的问题是它也应该是dafault资源。

可能是什么问题?

布局文件(现在复制/粘贴-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>

2 个答案:

答案 0 :(得分:7)

假设您实际上从日志中复制/粘贴了错误,那么您会输入错误信息:

  

java.lang.RuntimeException:无法启动Activity   android.view.InflateException:二进制XML文件行#16:错误   膨胀类android.view.ImageVeiw

ImageView在一个layout.xml文件中拼写错误。

答案 1 :(得分:3)

最后我意识到出了什么问题......手机有一个特殊的分辨率(960x540),它无法找到ImageView-s的源图像和此分辨率的维度文件 - 这就是为什么应用程序在其他手机上运行,​​如同他们使用“共同”解决方案。

感谢您的帮助,我很感激+1