本文译自Android官方技术文档《Migrating from IntelliJ Projects》,原文地址:http://tools.android.com/tech-docs/new-build-system/migrating-from-intellij-projects。
上1篇介绍了如何上1篇介绍了如何把1个Eclipse上的Android项目迁移到 Android Studio,这1篇继续介绍对 IntelliJ项目的迁移。
翻译不容易,转载请注明CSDN博客上的出处:
http://blog.csdn.net/maosidiaoxian/article/details/42736561
翻译工作耗时费神,如果你觉得本文翻译得还OK,请点击文末的“顶”;如有错讹,敬请指正。谢谢。
res/, src/)
而不是用 Gradle 项目的默许新目录结构 (src/main/java/, src/main/res/等)。下面给出1个示例 gradle 文件。gradle assembleDebug可以测试您的构建。如果你之前不是用 Gradle 来构建的,需要从 http://www.gradle.org/downloads 中安装它。请注意,当您通过
Studio 创建新项目时,我们会在项目的根目录创建1个 gradle wrapper 脚本 (“gradlew”和“gradlew.bat”),所以该项目的任何用户只需在你的项目中运行“gradlew assembleDebug”等命令,gradle 就会自动下载和安装。但是,您现有的 IntelliJ 项目大概还没有这个 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') }}