[Android] Error highlights and Solutions

Source: Internet
Author: User

Error 1: The application has stopped unexpectedly

Explanation: The application stops unexpectedly.

Solution: 1) first check Java file logic problems, such as force type conversion error

Privateimagebutton button;

Button = (button) findviewbyid (R. Id. Button );

There are other types of errors, which are not provided here

2) my first response was the XML file configuration error.

Check the layout folderAnd values filesSee if there is a syntax error in the XML file.

Here is an invisible error that is hard to find.

Because the code is changed multiple times, the code is generated and the code is run. This causes file disorder in the project. An unrecognized error occurs when you add an XML file or add elements in the XML file again. Even if the syntax you write is correct.

Solution: Right-click the Agency and choose clean and generate

3) if multiple java files are written, I will pay attention to the modification of androidmanifest. xml.

<Activity Android: Name = "maintab">
</Activity>
<Activity Android: Name = "localmusic">
</Activity>

4) if the program requires networking, and androidmainfest. XML has no relevant configuration

You need to add: <uses-Permission Android: Name = "android. Permission. Internet"/>

2. Error 2: The function in the execution thread is always stopped for no reason

Solution: Use try () catch (exception) {} to include the statement to be executed to solve this type of error.

Related Article

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.