Android Studio First experience import Eclipse project

Source: Internet
Author: User

The version of Android Studio used in this article is 1.0, Eclipse ADT version 22.3.0.

This article mainly introduces two kinds of import methods:

    1. Use Eclipse to export to gradle build files, and then import the project directly from Android Studio.
    2. Import the Eclipse project directly with Android Studio.

Android Studio uses Gradle to build projects by default, and Eclipse uses Ant to build projects by default. It is recommended that Android studio build the project using Gradle when importing the project.

Export Eclipse Project In this example, use the Eclipse project structure

1.file–> Export:

2. Select the export type.

Select android–> Generate Gradle build files:

3. Select the project you want to export and click Next:

4. Finalize the project that you want to export.

Force overriding of existing filesRepresents overwriting an export file. By exporting the project using Generate Gradle build files, some files are generated in the project directory. The overwrite file here refers to overwriting the files that may have been generated. If you have previously exported items in this way, it is recommended to tick.

Click Finish. The Export prompt box appears:

5. Export effects

Finish clicked, and no pop-up window shows the exported item as if nothing had been done. In fact, using this method to export the project, is to add some files in the project, we can go to the project directory to look at these build files.

The Working space directory is as follows:

Can be found in the workspace directory, the Gradle folder and Build.gradle, Gradlew, Gradlew.bat and other files. These files and folders are related to Gradle and are used to build the project. These files and the role of the folder, we will talk about later.

6.manually modify Gradle related configuration (important)

Since Eclipse's ADT plugin has not been updated for a long time, the auto-generated Gradle compilation settings have not been keeping up with the update speed of Android studio, so we need to manually modify some of the content.

Open the Gradle–> wrapper–> in the workspace directory gradle-wrapper.properties . Modify the content:

Distributionurl=http://services.gradle.org/distributions/gradle-a.b.c-all.zip–> distributionUrl=https:// Services.gradle.org/distributions/gradle-2.2.1-all.zip

Open the file under the workspace directory build.gradle . Modify the following content:

classpath ' com.android.tools.build:gradle:0.x.+ ' –> classpath ' com.android.tools.build:gradle:1.0.0 ' .

This is set because the Gradle settings that Eclipse exported are not already Gradle plug-in versions supported by Android Studio 1.0 and require a manually more supported version. Otherwise, you must not import the project offline, and the project import fails.

When online, Android Studio will download the corresponding bar Gradle version (as in this example gradle-a.b.c-all.zip), very time-consuming, perhaps also to turn over the wall!

Android Studio import Eclipse Project 7. Open Android Studio and choose Open an existing Android studio project.

8. A box will pop up and select the Hello project folder:

Click OK.

9. Set import options.

Here are some more important settings to explain.

    • Gradle Project: The path that is typically shown here is not the directory of your eclipse's workspace, but the Gradle path in the directory of your eclipse's workspace. You need manually delete the following gradle , otherwise the project will be imported, you will not see your code, you can only see the contents of the Gradle directory.

    • Create directories for empty content roots automatically: not very clear about its role, the general default can be.

    • Uses default Gradle wrapper (recommended) and use local Gradle disribution: These are the gradle that you set up with. By default, the use default Gradle wrapper (recommended) is checked, and we need to manually tick the local gradle disribution.

    • Gradle Home: Check the use local Gradle disribution after this program is editable state, the default address here is the Gradle path address in the Android Studio installation directory. There may be some false warnings, as follows: Gradle is incorrect. And you have this directory, there is indeed a Gradle. The cause of this problem is most likely due to the Gradle home option, where the slash in the path is/instead of * * . You need to click the left and right file selection button and re-select the * * Gradle in the Android Studio installation directory to resolve the issue.

    • Offline work: Set Gradle to import items offline. You can check it or uncheck it. If you have manually modified the Gradle related configuration before you proceed, you can check it out and compile it offline.

Click OK. After that you will see the compilation progress bar, depending on the configuration of each machine, the compilation time is different.

If you see the following interface, you have already imported the success.

Import an Eclipse project directly

If you do not export your project using Generate Gradle build Files , you can use Android Studio to open the Eclipse workspace directly for project import.

12. Open Android Studio and select Import non-android Studio project.

In the pop-up directory selection box, select the Eclipse project:

Confirm Selection:

can see:

Importing a project creates afull copy of the project and does not alter the original Eclipse project.

The import project, literally, is a full copy of the source Eclipse project and does not change the source project.

Click Next

Finish

Page hints: The ADT Project Import tool will identify some .jar files even the entire Lib source file and use the Gradle dependency to replace them. However, it is not possible to calculate which version of the library is used, so the latest is used. If your project needs to be adjusted to compile with the latest library, you can choose to re-import the project and cancel the selections below, or better to update your project.

Wait for the Gradle build project

The final import succeeds and a file is generated import-summary.txt :

Get.

Reference:

Http://ask.android-studio.org/?/article/21

Android Studio First experience import Eclipse project

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.