Possible exceptions during code migration from Eclipse to Android Studio, eclipseandroid

Source: Internet
Author: User

Possible exceptions during code migration from Eclipse to Android Studio, eclipseandroid
Preface:

Google is gradually stopping its development of Eclipse. Now Android Studio is becoming the first choice for Android development. Although there may be some pain points, when everyone is familiar with using Android Studio, we will feel that Google's decision to change Android development IDE is correct. Android Studio indeed gives Android Developers a better experience and development environment. Next, let's talk about the problems we encountered when migrating from Eclipse to Android Studio. You may have read many summary about problems that may occur in Android Studio. However, I wrote this article mainly about the problems that will occur when the original project code is migrated from Eclipse to Android Studio, and it does not have much to do with the configuration of Android Studio.

Exception:

An anonymous internal class calls an external class variable and must be declared as final.

This is the first problem I encountered when migrating an Eclipse project to Android Studio and building it using Gradle (I have migrated the code to Android Studio before using Gradle for building, only the original Eclipse structure is used). The exception is shown in:

This problem occurs mainly because too many callbacks are used in my project. At the same time, these callbacks will generate interface Dialog elements during implementation. Click events in Dialog must use callback parameters again, it is reasonable to say that this situation is indeed because anonymous internal classes call external class variables, but there was no exception in Android Studio (Eclipse structure) or Eclipse in the past, I suddenly broke out when I switched to Gradle, so I had to fix all the exceptions in the project one by one and add the final modifier to the variables.

Custom or third-party control declaration

When we write the layout file, there is a default name space (namespace), namely:Xmlns: android = "http://schemas.android.com/apk/res/android"However, when using third-party or custom controls, you need to add an additional naming control to them. The fixed format is: xmlns: app = "http://schemas.android.com/apk/res/packagename].PackagenameFor your project package name,AppYou can customize a field. These are just the namespaces written in Eclipse. It is easier to write namespaces for third-party and custom controls on Android Studio. You can simply write them as xmlns: app = "http://schemas.android.com/apk/auto-res, you do not need to include a troublesome package name. Of course, if you use Gradle to build Android Studio, you cannot compile the package without writing it like this.

Exceptions generated by the. 9 graph during compilation

Recently, I encountered the following exceptions during project Compilation:

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

This exception occurs because I am in. 9 There are two lines on the right side of the figure, because. 9. The upper boundary and left boundary dashes are used to stretch and expand, while the lower boundary and right boundary dashes are the content area. 9. The Right and bottom boundary are not allowed to have two dashes, while the left and upper boundary are OK.

Reference link:

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

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.