Android 安卓应用程序在HTC和索尼爱立信手机上崩溃

Android 安卓应用程序在HTC和索尼爱立信手机上崩溃,android,crash-reports,sony,htc-android,Android,Crash Reports,Sony,Htc Android,我们今天在市场上发布了该应用程序-。我收到报告说,该应用程序在HTC和索尼爱立信手机上崩溃。我从一个用户那里得到了以下日志报告 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.m7.nomad/com.m7.nomad.SplashActivity}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x

我们今天在市场上发布了该应用程序-。我收到报告说,该应用程序在HTC和索尼爱立信手机上崩溃。我从一个用户那里得到了以下日志报告

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.m7.nomad/com.m7.nomad.SplashActivity}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x3
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x3
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:5459)
at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1776)
at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1700)
at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:56)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:741)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2707)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2767)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:247)
at android.app.Activity.setContentView(Activity.java:1835)
at com.m7.nomad.SplashActivity.onCreate(SplashActivity.java:46)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
... 11 more
第46行指向
setContentView(R.layout.activity\u splash)

活动\u splash.java

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/primary_color" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:contentDescription="Splash Screen"
        android:gravity="center"
        android:src="@drawable/splash_logo" />

</RelativeLayout>

在项目中应用此xml,看看会发生什么:)


在您的溅涂布局中使用此选项

<?xml version="1.0" encoding="utf-8"?>
 <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffe5492a"
android:contentDescription="Splash Screen"
android:scaleType="fitCenter"
android:src="@drawable/splash_logo" >


崩溃的原因可能隐藏在你的风格中。它可能包含一个引用Android SDK中包含的维度的属性,而您在不包含该维度的旧版本SDK上运行应用程序

,作者使用了以下属性:

android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
然而,正如公认的答案所指出的,in
android.R.attr
仅在SDK级别14以后才可用


删除、替换或分离资源文件,使其符合SDK级别。例如,您可以在
res/values-14
中提供一种样式,而在
res/values

中的版本中省略这些条目。您可能希望共享一些代码。。。尤其是坠毁的那部分。否则,我们可以说的最明智的事情是:“您有一个bug”,您的
SplashActivity
的布局似乎有问题。请发布布局的
xml
com.m7.nomad.SplashActivity.onCreate(SplashActivity.java:46)中的代码activity@Veger添加了代码:)@Evos也共享了活动的代码您真的确定您的相对布局需要这2个标签吗:
android:textalign=“center”
android:gravity=“center”
。你能试着把它们拿走吗?该死的,我没有htc手机。。测试:P将返回报告:D您是否在清单中设置了相同的包名?共享更多的启动活动代码和xml文件。我可以将其发送给您,以便不必公开共享该文件吗?我找不到您的电子邮件id:D我为什么不能使用布局?我需要填充一个背景色,你可以使用
android:background=“@color/primary\u color”
如果你喜欢,顺便说一句相同的颜色:知道为什么会这样吗???我的意思是为什么它只发生在HTC上。我没有htc供我使用。从朋友那里检查:我猜android:textAlignment=“center”
在HTC设备上有问题,只是猜测而已……)这里有一个提示,启动AboutActivity或MainActivity而不是SplashActivity。如果它仍然崩溃,那么问题在于你的主题,从你的清单中删除这个标签
android:theme=“@style/theme.Nomad”
,它肯定会工作。如果它有效的话,那么你就会知道去哪里看。移除它们只是工作得很好,没有改变任何东西,所以我们现在已经这样做了。感谢您指出如何使用value-14来适应相同的需求。我会试试看,然后告诉你:D
context = this;
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
<?xml version="1.0" encoding="utf-8"?>
 <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffe5492a"
android:contentDescription="Splash Screen"
android:scaleType="fitCenter"
android:src="@drawable/splash_logo" >
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"