Migration of code from eclipse to Android studio exceptions that may occur

Source: Internet
Author: User

Objective:

Google is gradually stopping the development of Eclipse, now Android Studio is becoming the first choice for Android development, although there will be some pain, but when everyone is familiar with the use of Android studio, will feel that Google transform Androi D The decision to develop the IDE is correct, and Android Studio does give Android developers a better experience and development environment. Let me talk about some of the problems that I experienced when migrating from Eclipse to Android Studio. You may have read a lot about possible problems in Android studio, but I wrote this article mostly about issues with the project's original code migrating from Eclipse to Android studio, and not with Android studio Too much of a relationship.

Abnormal:

Anonymous inner class calls external class variables need to be declared final

This is the first problem I encountered when I migrated the Eclipse project to Android Studio and built it with Gradle (I migrated the code to Android studio before using Gradle, just using the original eclipse structure). The exception is as follows:

This problem occurs mainly because I use too many callbacks in my project, and when these callbacks are implemented there will be an interface dialog element, and the click events in the dialog need to use the parameters in the callback again, it is true that the anonymous inner class calls to the external class variable, but previously At the time of Android Studio (eclipse structure) or eclipse, there was nothing unusual, and when I switched to Gradle build it broke out all of a sudden, so I could only fix all of this exception one by one in my project and add the final modifier to the variable.

Custom or third-party control declarations

When we write layout layouts, we have a default name space (namespace), which is:xmlns:android= "Http://schemas.android.com/apk/res/android" , but when we use third-party or custom controls, we need to add an additional named control to them, usually in a fixed format: xmlns:app= "Http://schemas.android.com/apk/res/packagename", The packagename section is the package name for your project, and theapp can customize a field yourself. These are just the namespaces on Eclipse, and it's easier to write namespaces for third parties and custom controls on Android Studio, and write them directly as xmlns:app= "http://schemas.android.com/apk/ Auto-res "Can, without the hassle of the package name, of course, if you are in Android Studio and use Gradle build, do not write this will not be compiled.

Compile-time. 9 Graph-generated exceptions

The following exception occurred when I recently compiled the project:

Error:Can‘t have more than one marked region along edge.

This exception occurs because I have drawn two lines on the right side of the. 9 graph, because the top and left edges of the. 9 chart are stretched and the bottom and right borders are the content area, so the. 9 figure does not allow two dashes to the right and bottom boundaries, and the left and top boundaries are not problematic.

Reference Links:

Http://stackoverflow.com/questions/27448559/android-studio-1-0-compile-error-cant-have-more-than-one-marked-region-along

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Migration of code from eclipse to Android studio exceptions that may occur

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.