From Eclipse to Android studio

Source: Internet
Author: User
Tags lenovo

This article explains how the Android project is exported from Eclipse to Android studio, which is referred to as studio and is compatible with both environments.


Android Studio is Google's official push of Android development IDE, compared with eclipse, there are many advantages, such as:

    • Log more humane, there are various tags, URLs can be directly clicked, you can directly select Copy. Eclipse replication is more troublesome, occasionally rolling, more bugs
    • Studio can use the network path to rely on the supported jars for a clearer structure. Eclipse encounters the problem: "The referenced two libraries have their own support-v4.jar, requiring a unified version to be heavy"
    • Many of the open source projects use Studio
    • Studio to make multi-channel packages more convenient
    • Studio's Lenovo function is more powerful, such as "Ic_loading_selector.xml", lose load can be Lenovo, code code silky Smooth
    • Studio syncs changes to files instantly, eliminating the steps of Eclipse refresh and clean
    • More tools for studio, easier commissioning
    • Studio integrates version control tools for easier submission
    • Stdudio more modularity with project management of multiple module modules
of course, studio also has drawbacks:

    • Pre-edit native C code without eclipse convenience
    • Slightly heavier relative to eclipse project
    • Older projects are more mature and moving to gradle increases the risk for the project. Increase learning costs
    • Some dependent files need to be turned over the wall.
    • Different programmers write Gradle version of the project, in the import of other projects may be loaded gradle supporting files, and this supporting file is large, time is slow, the UI has only one loading state, download need to flip the wall, resulting in failure. (This file can be downloaded directly from Thunder and then put in the specified directory.) Under Windows, the directory location is "C:\Users\administrator\. " Gradle \wrapper\dists ", corresponding to"/home/user name "under Linux) such as:

    • Some people think that studio is slow to compile. In fact, the compiler is slow mainly because the default compilation is to perform online compilation, offline compilation is simply silky smooth. Compile speed Optimization article reference: Gradle build Speed accelerates the ultimate approach


Personal feeling, switching to studio or more benefits, is also the trend.

The first is the single module Eclipse project exported to studio. The Eclipse Engineering directory structure is as follows:


There are two ways to export from Eclipse to studio:

    • Export the Gradle file using Eclipse and import from studio
    • Import directly from Studio
First , you export the Gradle file from Eclipse, and then import it into studio, with the following table of contents:


More files related to studio. During the import process, it is suggested that such an import would cause the engineering structure to be not studio-style, and that studio would recommend a studio-style import, not recommended, and might encounter some problems later.

Both Ides now have the ability to open the project.

Here is the second result of importing the Eclipse project directly into studio:


There is a set of project-corresponding profiles on the outer layer, and Eclipse's only module, named App,module, has its own gradle file in the style of studio as well.

Now compatible with Eclipse, you need to do a bit of work:

    • Copy Lib to the Src/main directory, and keep it consistent with eclipse.
    • Copy the engineering configuration file from the original eclipse to the Src/main directory, and stay consistent with eclipse
    • Studio source is the Java path, modify the source path of Eclipse to Java
    • Specify LIB to a new location, add jar dependency, NDK configuration, mainly modify the app's module's Build.gradle file. For reference: Introduction to the Build.gradle of Android Studio

The results are as follows:

where SH is the original directory, and the project is unrelated to some script files, can be ignored. . Classpath and. Project are project files for Eclipse. Gitignore is an ignored configuration file that was submitted to git by the original Eclipse project. Project.Properties is the project properties file for Eclipse. Proguard-project.txt is a confusing-related configurationIc_launcher-web.png also copied over, the function:Can ic_launcher-web.png be erased?
many projects on GitHub use a similar configuration.

With regard to multi-module eclipse projects imported into studio, I only researched the direct import method recommended by Google, that is, the method that does not generate gradle in eclipse. Example:
the project in the diagram is Project for Eclipse, which contains a main module, a Lib module. when studio selects the Import folder, do not select Sample-master This directory, I tried once, the results of the new project is chaotic, and can not add network dependent support jar. The correct method should select the sample folder. if eclipse is dependent on normal, studio detects two module relationships when importing, and automatically creates a module folder for sample and Sample-lib in the new project. of course, if you want to support eclipse, you need to write the previous action.
Finally, add the Eclipse module to the multi-module studio project where OK is already configured, import it directly, and then perform the previous operation to copy the eclipse file to Src/main. and before writing an article, using the first export from Eclipse Gradle then imported into studio method, feel bad, can be eliminated:the correct posture for Eclipse import into Android studio

From Eclipse to Android studio

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.