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

标签 android crash-reports sony htc-android

我们今天在市场上发布了该应用程序 - Nomad .我收到有关该应用程序在 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

无法理解为什么会这样。

SplashActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;

    // Remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.activity_splash);

    // Shared Preferences
    settings = getSharedPreferences(SETTINGS_PREFS, 0);

    configRun = settings.getInt("database_version", 0);

    this.assetManager = this.getAssets();


}

第46行指向setContentView(R.layout.activity_splash);

activity_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>

最佳答案

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

In this example ,作者使用了以下属性:

android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"

但是,正如已接受的答案所指出的那样,listPreferredItemPaddingLeft entry android.R.attr 仅适用于 SDK 级别 14 及更高版本。

要么删除有问题的条目,替换它们,要么分离资源文件,使其符合 SDK 级别。例如,您可以在 res/values-14 中提供一种样式,而在 res/values 中省略版本中的那些条目。

关于Android 应用程序在 HTC 和索尼爱立信手机上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14454024/

相关文章:

java - 方法中 "too many"局部变量的性能影响?

objective-c - UIKit : [UIViewController mutableChildViewControllers] crash?

android - 如何检测智能 watch 何时与智能扩展 API 断开连接/注销

android - 如何知道我的 Android SmartWatch 扩展是否处于非 Activity 状态?

java.net.绑定(bind)异常 : bind failed: EADDRINUSE

android - 如何在 FragmentStatePagerAdapter 中动态添加页面

ios - 如何解读 iOS 的这些崩溃报告

android - 从 Thread.UncaughtExceptionHandler 启动服务?

javascript - 索尼 Bravia JavaScript API 和模拟器

android - 我可以更改 Android 应用程序的语言吗?