Android official technical document translation--intellij Project migration

Source: Internet
Author: User

This article is translated from the official Android technical document "Migrating from IntelliJ Projects", the original address: http://tools.android.com/tech-docs/ New-build-system/migrating-from-intellij-projects.

The previous article described how the previous article introduced how to migrate an Android project on Eclipse to Android Studio, which continues to introduce the migration of the IntelliJ project.

Translation is not easy, reprint please indicate the source of CSDN blog:

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

If you think the translation is OK, please click on the "Top" at the end of the article, if you have inappropriateness, please correct me. Thank you.


IntelliJ Project Migrationin the future, we may provide options for automatic migration in Android Studio.
Now, to migrate your IntelliJ project to an Android Gradle project (which can be imported to IntelliJ and then directly supported in IntelliJ), you need to follow these steps:
  • Create a basic "Build.gradle" file.  With the default Gradle file file created by Android Studio when you create a new project, the following Gradle file will point the source code directory to an existing folder (for example res/ , src/ ) instead of using the default new directory structure of the Gradle project ( src/main/java/ , src/main/res/, etc.). A sample Gradle file is given below.
  • Determine which library project (such as Actionbarsherlock) you are using. In Gradle you no longer need to add these libraries as source code items, you can simply reference them with dependencies, and the build system will process the next sections, download, merge resources and inventory items, and so on. For each library, the dependent name of the appropriate AAR library is found (provided that the library being discussed has been updated as an archive for an Android library) and then added to the dependent section.
    • To find the appropriate declaration statement for the library, you may find that the following blog is useful for you: http://gradleplease.appspot.com/
  • You can test your build by running it in your project gradle assembleDebug . If you didn't build it with Gradle before, you need to install it from Http://www.gradle.org/downloads. Note that when you create a new project through Studio, we create a gradle wrapper script ("Gradlew" and "Gradlew.bat") at the root of the project, so that any user of the project simply runs in your project "Gradlew Assembledebug "command, Gradle will be downloaded and installed automatically. However, your existing IntelliJ project probably does not yet have this gradle script.
  • Note that the IntelliJ 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, see the User Guide for the new build system for more information on how to customize your build. For additional information, see the Overview page of the build system.

Android official technical document translation--intellij Project migration

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.