"Android Troubleshooting the second case" unsupportedoperationexception

Source: Internet
Author: User

Although this bug ultimately lies in the problem of can ' t convert to dimension:type=0x3, the analytical idea is how to narrow down the scope step by step to find the real error.
The error is:
Java.lang.RuntimeException:Unable to start Activity componentinfo{com.work.gongchenglion/ Com.work.gongchenglion.ui.ResultActivity}: Java.lang.UnsupportedOperationException:Can ' t convert to Dimension:type =0x3

Analysis 1:
We are used to getting rid of errors from the beginning, because the front exception is the base class behind, the information on the web is more, and it conforms to our behavior habits.
But the final hint, such as "Can ' t convert to dimension:type=0x3," often has a scalpel-like precision, to the problem.
But it was clear that at first I could not understand the meaning of "Can ' t convert to dimension:type=0x3," or what type 0x3 represented was wrong. So I sort out all the useful information and guess what the real understanding is?
("Can ' t convert to dimension:type=0x3" means "cannot be converted to dimensions, labeled as 0x3 bug type")

Analysis 2:
Information in the Logcat:
1. Java.lang.RuntimeException:Unable to start Activity componentinfo{com.work.gongchenglion/ Com.work.gongchenglion.ui.ResultActivity}: Java.lang.UnsupportedOperationException:Can ' t convert to Dimension:type =0x3
2, at Android.app.Activity.setContentView (activity.java:1835)
Seize valid information:
1), unable to start activity componentinfo:
The activity component could not be opened. This could be an issue where manifest.xml did not declare or declare the error (possibly the path problem of the declared component), at which point I was not busy trying to modify it and simply marked it with a tree diagram. Because our goal is to figure out what "Can ' t convert to dimension:type=0x3" means.
2), Unsupportedoperationexception:
The operation does not support errors. Ditto, there are also many possibilities, such as the current SDK version does not support some outdated components or APIs. At this point, I think it may be the reason that a component is obsolete. Still marked.
3), Can ' t convert to Dimension:
cannot be converted to dimensions. Here I suspect that I have defined an error in the size of the dimens.xml. A missing or conflicting dimension. It took me a long time to check, in fact, to understand the error.
4), at Android.app.Activity.setContentView (activity.java:1835):
The problem of layout is obvious. Confine your attention to the XML file that invokes the method.
5), type=0x3:
Ask over Niang, Chinese online The only "type=0x3" type of error, in a Java file, get a property through Getresourceid to get a resource. It is clear that the information 4 contradicts. But here I know that "dimension" is really size, but refers to the size of the system from the resource file.
It also means that the "can ' t convert to Dimension" is not properly dimensioned from the XML resource file.

So I focus on some of the wrong API, and size, so I found android:layout_margintop= "Strings/layout_margin", using strings multiplexing dimension information is not allowed, In this case, the string class cannot convert the int class. Must use Demens.

"Android Troubleshooting the second case" unsupportedoperationexception

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.