Migrating from IntelliJ Projects

简介: We might provide an automatic migration option in Android Studio in the future.   For now, to migrate your IntelliJ project to an Android Gradle pro...
We might provide an automatic migration option in Android Studio in the future.
 
For now, to migrate your IntelliJ project to an Android Gradle project (which can then be imported into IntelliJ and supported directly in IntelliJ), follow the following steps:
  • Create a basic "build.gradle" file. Unlike the default Gradle file created by Android Studio when you create a new project, the following gradle file will point the source code directories to the existing folders (e.g. res/src/) instead of the default new directory structure used for Gradle projects (src/main/java/src/main/res/, etc). A sample gradle file is given below.
  • Identify which library projects you are using (such as ActionBarSherlock). In Gradle you no longer need to add in these libraries as source code projects; you can simply refer to them as dependencies, and the build system will handle the rest; downloading, merging in resources and manifest entries, etc. For each library, look up the corresponding AAR library dependency name (provided the library in question has been updated as a android library artifact), and add these to the dependency section.
  • Test your build by running gradle assembleDebug in your project. If you have not built with Gradle before, install it from http://www.gradle.org/downloads. Note that when you create new projects with Studio, we create a gradle wrapper script ("gradlew" and "gradlew.bat") in the project root directory, so any users of the project can just run "gradlew assembleDebug" etc in your project and gradle is automatically installed and downloaded. However, your existing IntelliJ projects presumably does not already have the gradle scripts.)
  • Note that IntelliJ projects for Android generally follow the same structure as Eclipse ADT projects, so the instructions in the Eclipse migration guide might be helpful.
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')
    }
}
For more information on customizing your build once you have the basics set up, see the new build system  user guide. For additional information, see the build system  overview page.

http://tools.android.com/tech-docs/new-build-system/migrating-from-intellij-projects

 

相关文章
|
1月前
|
Java Android开发
eclipse导入项目时,报错:One or more cycles were detected in the build path of project ....
eclipse导入项目时,报错:One or more cycles were detected in the build path of project ....
|
5月前
|
人工智能 Java Maven
idea_download meaven问题
idea_download meaven问题
48 0
|
11月前
|
JavaScript 前端开发
01-day projects
01-day projects
50 0
|
Java Maven
intellij IDEA--- 报inspects a maven model for resolution problems
intellij IDEA--- 报inspects a maven model for resolution problems
242 0
|
Java Android开发
eclipse中提示change project compliance and jre to 1.7
eclipse中提示change project compliance and jre to 1.7
107 0
eclipse中提示change project compliance and jre to 1.7
|
开发工具 git
IntelliJ IDEA - 如何添加 Git 到 Project?
IntelliJ IDEA - 如何添加 Git 到 Project?
92 0
IntelliJ IDEA - 如何添加 Git 到 Project?
|
存储 IDE 搜索推荐
谁再把IDEA的Project比作Eclipse的Workspace,我就跟谁急
谁再把IDEA的Project比作Eclipse的Workspace,我就跟谁急
谁再把IDEA的Project比作Eclipse的Workspace,我就跟谁急
|
存储 搜索推荐 前端开发
IDEA中每天都在用的Project Structure,你了解多少?
IDEA中每天都在用的Project Structure,你了解多少?
776 0
IDEA中每天都在用的Project Structure,你了解多少?
|
Android开发
Eclipse plugin folder
Eclipse plugin folder
Eclipse plugin folder
IDEA Cannot load project: com.intellij.ide.plugins.PluginManager$StartupAbortedException:解决
IDEA Cannot load project: com.intellij.ide.plugins.PluginManager$StartupAbortedException:解决