码迷,mamicode.com
首页 > 编程语言 > 详细

java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1

时间:2016-01-29 03:41:08      阅读:410      评论:0      收藏:0      [点我收藏+]

标签:unsupportedoperationexception   androidruntime: fatal exception: main   java.lang.runtimeexception: unable to start activity componentinfo   

遇到这个bug: 末尾是解决方法。
 E/AndroidRuntime: FATAL EXCEPTION: main
                                                                        Process: com.XX.XX.XX, PID: 7055
                                                                        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.XX.XX.XX./com.test.MAinActivity}: java.lang.UnsupportedOperationException: Can‘t convert to dimension: type=0x1
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
                                                                            at android.app.ActivityThread.access$800(ActivityThread.java:143)
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                            at android.os.Looper.loop(Looper.java:136)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5120)
                                                                            at java.lang.reflect.Method.invokeNative(Native Method)
                                                                            at java.lang.reflect.Method.invoke(Method.java:515)
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:818)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
                                                                            at dalvik.system.NativeStart.main(Native Method)
                                                                         Caused by: java.lang.UnsupportedOperationException: Can‘t convert to dimension: type=0x1
                                                                            at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:464)
                                                                            at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:6155)
                                                                            at android.widget.RelativeLayout$LayoutParams.<init>(RelativeLayout.java:1225)
                                                                            at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:1062)
                                                                            at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:82)
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:757)
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                                                                            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
                                                                            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
                                                                            at com.financial360.nicaifu.framework.ui.base.NcfActivity.setContentView(NcfActivity.java:98)
                                                                            at com.financial360.nicaifu.ui.base.BaseActivity.setContentView(BaseActivity.java:61)
                                                                            at com.financial360.nicaifu.ui.dq.BuyDqDetailsActivity.onCreate(BuyDqDetailsActivity.java:119)
                                                                            at android.app.Activity.performCreate(Activity.java:5343)
                                                                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257) 
                                                                            at android.app.ActivityThread.access$800(ActivityThread.java:143) 
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209) 
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                            at android.os.Looper.loop(Looper.java:136) 
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5120) 
                                                                            at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                            at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:818) 
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634) 
                                                                            at dalvik.system.NativeStart.main(Native Method) 
01-28 09:04:42.252 927-976/? E/OppoPhoneWindow: OppoPhoneWindow

 

出现此类问题有很多缘故,但是其根源还是在xml中,比如你在用dimens文件的时候,你在values-w360dp 文件夹下定义了 dimen数值,但是你在values文件夹下没有定义那个数值,在这种情况下如果你手机分辨率比较小的时候它默认是从values文件夹取值的,当Rendering的时候,去默认的values下找不到数值就会报错。

同理 style,color等等要在默认的values要优先在默认的values中定义。在values-w360dp values-w480dp values-w600dp 中有的数值,在默认的values中一定要有。

本文出自 “知行合一” 博客,请务必保留此出处http://poarry.blog.51cto.com/5970996/1739672

java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1

标签:unsupportedoperationexception   androidruntime: fatal exception: main   java.lang.runtimeexception: unable to start activity componentinfo   

原文地址:http://poarry.blog.51cto.com/5970996/1739672

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!