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 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

 

时间: 2024-07-29 17:37:26

Migrating from IntelliJ Projects的相关文章

IntelliJ IDEA常见问题解决办法汇总

必备材料介绍 IntelliJ IDEA 对其他 IDE 转过来的用户有特别优待,对其专门整理了非常棒的资料,还请其他 IDE 过来的用户抽时间查看,会有很大帮助: Eclipse 用户可以看:https://www.jetbrains.com/idea/help/eclipse.html NetBeans 用户可以看:https://www.jetbrains.com/idea/help/netbeans.html Project 和 Module 介绍 这两个概念是 IntelliJ IDE

急!-idea14 maven projects dependencies出现波浪线,导入不到项目中

问题描述 idea14 maven projects dependencies出现波浪线,导入不到项目中 解决方案 idea 14创建maven项目(一)IntelliJ IDEA14 导入 maven项目 解决方案二: 方法1.查看 file--projectStructure 这一块 有没有报错 方法2.Import Maven projects automatically 方法3.右键项目reimport 方法4.最后可以重新创建项目,将代码在复制过来

lombok在IntelliJ IDEA下的使用

      lombok是一款可以精减java代码.提升开发人员生产效率的辅助工具,利用注解在编译期自动生成setter/getter/toString()/constructor之类的代码.代码越少,意味着出bug的可能性越低. 官网地址:https://projectlombok.org/ 首页有一段几分钟的演示视频,看完就明白是怎么回事了. 先来二段对比代码: 这是用lombok后的java代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1

Getting Started with Intellij Idea (10.5.1)

This document guides you through the process of writing and compiling a 'Hello World' type program using Intellij Idea. First of all, find Intellij Idea on the desktop or start menu (look for IntelliJ IDEA under All Programs) and open the application

使用IntelliJ IDEA开发SpringMVC网站(五)博客文章管理

原文:使用IntelliJ IDEA开发SpringMVC网站(五)博客文章管理 摘要 通过对博客文章的管理,实现外键操作. 目录[-] 八.博客文章管理 1.查看文章 2.添加博客        3.查看博文详情 4.修改博客内容 5.删除博客文章 九.尾声         1.如何部署 2.进一步的学习 3.ENDING 转载请注明出处:Gaussic(一个致力于AI研究却不得不兼顾项目的研究生) . 注:在阅读本文前,请先阅读: 使用IntelliJ IDEA开发SpringMVC网站(一

IntelliJ IDEA 2016.3.1 发布,Java 开发工具

IntelliJ IDEA 2016.3.1 发布了.如果你还没有尝试 IntelliJ IDEA 2016.3,那么欢迎使用 IntelliJ IDEA 2016.3.1,本次更新带来了很多重要的错误修正.其中最显著的变化之一是实现了对 JUnit 5 M3 的支持,因此如果您计划继续运行JUnit 5 M2,您必须使用IntelliJ IDEA 2016.3(或更早版本),或手动包括JUnit 5 M2 你的类路径中的属性. 至于 JDK 9,IntelliJ IDEA 2016.3 将不支

Gradle精选: 在IntellIJ IDEA中创建快捷方式,用于刷新Gradle工程

翻译自: http://mrhaki.blogspot.com/2017/03/gradle-goodness-create-shortcut-key-to.html 我们可以在IntelliJ IDEA中打开一个Gradle工程,并且获得IntelliJ对Gradle的原生支持.当我们在Gradle build文件中添加一个新的依赖或者插件时,需要在 IntelliJ IDEA中刷新工程.我们需要刷新这个Gradle工程,来保证IntelliJ IDEA 能够同步这些改变.Gradle工具栏有

IntelliJ IDEA + Maven环境编写第一个hadoop程序

1. 新建IntelliJ下的maven项目 点击File->New->Project,在弹出的对话框中选择Maven,JDK选择你自己安装的版本,点击Next   2. 填写Maven的GroupId和ArtifactId 你可以根据自己的项目随便填,点击Next 这样就新建好了一个空的项目 这里程序名填写WordCount,我们的程序是一个通用的网上的范例,用来计算文件中单词出现的次数   3. 设置程序的编译版本 打开Intellij的Preference偏好设置,定位到Build, E

【转】Intellij IDEA 14中使用MyBatis-generator 自动生成MyBatis代码

Intellij IDEA 14 作为Java IDE 神器,接触后发现,非常好用,对它爱不释手,打算离开eclipse和myeclipse,投入Intellij IDEA的怀抱.      然而在使用的过程中会发现Intellij IDEA也有一些不尽如意的地方,难免会有些不爽:Intellij IDEA 的插件库远不及eclipse的丰富. mybatis-generator在eclipse中有专门的插件,而没有开发出Intellij IDEA能够使用的插件.     不过不用灰心,如果你的