Official Android Technical Documentation translation-IntelliJ project migration, androidintellij

Source: Internet
Author: User

Official Android Technical Documentation translation-IntelliJ project migration, androidintellij

This article is translated from the official Android Technical Documentation Migrating from IntelliJ Projects. Original address: http://tools.android.com/tech-docs/new-build-system/migrating-from-intellij-projects.

The previous article describes how to migrate an Android project on Eclipse to Android Studio. This article continues to introduce the migration of IntelliJ project.

It is not easy to translate. For more information, see the source on the CSDN blog:

Http://blog.csdn.net/maosidiaoxian/article/details/42736561

Translation is time-consuming. If you think the translation is still OK, click "TOP" at the end of the article. If any error occurs, please correct me. Thank you.


In the future, IntelliJ project migration may provide automatic migration options in Android Studio.
To migrate your IntelliJ project to the Android Gradle project (which can be imported to IntelliJ and then directly supported in IntelliJ), follow these steps:
  • Create a basic "build. gradle" file. The default Gradle File Created by Android Studio when you create a new project. The following gradle file directs the source code directory to an existing folder (for exampleres/,src/Instead of using the default new directory structure of the Gradle Project (src/main/java/,src/main/res/). The following is an example of the gradle file.
  • Determine which library project you are using (such as ActionBarSherlock ). In Gradle, you no longer need to add these libraries as source code projects; you can simply reference them with dependencies, and the building system will process the following parts; download, merge resources and configuration items. For each library, the dependencies of the corresponding AAR library will be searched (provided that the library discussed has been updated as an android library archive file ), then add them to the dependent part.
    • To find the appropriate statement about the library, you may find the following blog useful to you: http://gradleplease.appspot.com/
  • By runninggradle assembleDebugYou can test your build. If you didn't build it with Gradle before, you need to install it from the http://www.gradle.org/downloads. Note that when you create a new project through Studio, we will create a gradle wrapper script ("gradlew" and "gradlew. bat), so any user of this project only needs to run the "gradlew assembleDebug" command in your project, and gradle will automatically download and install it. However, your existing IntelliJ project probably does not have this gradle script.
  • Note: IntelliJ's Android project generally follows the same structure as the Eclipse ADT project, so the introduction in the Eclipse Migration Guide may be helpful to you.
Build. gradle: buildscript {     repositories {         mavenCentral()     }     dependencies {         classpath 'com.android.tools.build:gradle:0.5.+'     } } apply plugin: 'android'
dependencies {     compile fileTree(dir: 'libs', include: '*.jar') }
android {     compileSdkVersion 18     buildToolsVersion "18.0.1"
    sourceSets {         main {             manifest.srcFile 'AndroidManifest.xml'             java.srcDirs = ['src']             resources.srcDirs = ['src']             aidl.srcDirs = ['src']             renderscript.srcDirs = ['src']             res.srcDirs = ['res']             assets.srcDirs = ['assets']         }
        // Move the tests to tests/java, tests/res, etc...         instrumentTest.setRoot('tests')
        // Move the build types to build-types/<type>         // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...         // This moves them out of them default location under src/<type>/... which would         // conflict with src/ being used by the main source set.         // Adding new build types or product flavors should be accompanied         // by a similar customization.         debug.setRoot('build-types/debug')         release.setRoot('build-types/release')     } }
After you have completed the basic settings, for more information about how to customize your build, see the user guide for the new build system. For more information, see the overview page of the build system.

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.