Eclipse转Android Studio工程有两种方式,
一种是兼容Eclipse,两者都可以使用,一种是全新的Android Gradle Project。
这里使用的Android Studio版本为2.2.3
一、兼容模式
1. 在Eclipse中生存Gradle文件
File->Export->Android->Generate Gradle build files
一路Next。
选择你要转的工程,包括主工程和库工程。
点击完成。
2. 修改导出文件参数
1)修改build.gradle文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0" 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')
}
} dependencies {
compile project(':libs:libAAA')
compile project(':libs:libBBB')
}
classpath 'com.android.tools.build:gradle:2.2.3'
2.2.3 为Android Studio版本
dependencies {
compile project(':libs:libAAA')
compile project(':libs:libBBB')
}
libAAA和libBBB是类库工程
2)更新Gradle版本
路径: /gradle/wrapper/gradle-wrapper.properties
#Fri Mar 24 09:42:28 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
3. 导入到Android Studio
选择Import project,
找到工程路径,选择工程目录打开。
二、全新的Android Gradle Project
这个很简单。选择Import project, 选择需要转换的Eclipse工程。之后Builc完成就OK了。