本文介绍了Android的应用程序崩溃的HTC和索尼爱立信手机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们今天推出的市场应用程序 - 游牧。我得到的报告,该应用程序崩溃的HTC和索尼爱立信手机。我是从用户的一个得到了下面的日志报告。
了java.lang.RuntimeException:无法启动活动ComponentInfo {com.m7.nomad / com.m7.nomad.SplashActivity}:java.lang.UnsupportedOperationException:无法转换为尺寸:类型= 0x3中
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
在android.app.ActivityThread.access $ 600(ActivityThread.java:123)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1147)
在android.os.Handler.dispatchMessage(Handler.java:99)
在android.os.Looper.loop(Looper.java:137)
在android.app.ActivityThread.main(ActivityThread.java:4424)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:511)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:784)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
在dalvik.system.NativeStart.main(本机方法)
java.lang.UnsupportedOperationException:产生的原因无法转换为维度:类型= 0x3中
在android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
在android.view.ViewGroup $ MarginLayoutParams< INIT>(ViewGroup.java:5459)
在android.widget.LinearLayout $的LayoutParams< INIT>(LinearLayout.java:1776)
在android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1700)
在android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:56)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:741)
在android.view.LayoutInflater.inflate(LayoutInflater.java:489)
在android.view.LayoutInflater.inflate(LayoutInflater.java:396)
在android.view.LayoutInflater.inflate(LayoutInflater.java:352)
在com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2707)
在com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2767)
在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:247)
在android.app.Activity.setContentView(Activity.java:1835)
在com.m7.nomad.SplashActivity.onCreate(SplashActivity.java:46)
在android.app.Activity.performCreate(Activity.java:4465)
在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
... 11更多
@覆盖
保护无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
上下文=这一点;
//删除标题栏
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
的setContentView(R.layout.activity_splash);
//共享preferences
设置= getShared preferences(SETTINGS_ preFS,0);
configRun = settings.getInt(database_version,0);
this.assetManager = this.getAssets();
}
线46点,的setContentView(R.layout.activity_splash);
< XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:背景=@色/ primary_color>
< ImageView的
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_centerHorizontal =真
机器人:layout_centerVertical =真
机器人:contentDescription =闪屏
机器人:重力=中心
机器人:SRC =@可绘制/ splash_logo/>
< / RelativeLayout的>
在你飞溅的布局使用此
< XML版本=1.0编码=UTF-8&GT?;
< ImageView的的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:后台=#ffe5492a
机器人:contentDescription =闪屏
机器人:scaleType =fitCenter
机器人:SRC =@可绘制/ splash_logo>
We launched the app on the Market today - Nomad. I am getting reports that the app crashes on HTC and Sony Ericsson Phones. I got the following Log report from one of the USER.
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
Not able to understand why it happens.
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();
}
Line 46 points to 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>
解决方案
Use this in your splash layout
<?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的应用程序崩溃的HTC和索尼爱立信手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!