【发布时间】:2015-12-28 03:32:11
【问题描述】:
我正在尝试将我的项目从 Eclipse 移动到 Android Studio。 我尝试了两种方法:
在 Android Studio IDE 中使用 Import 导入当前项目。
将当前项目导出为成绩项目
(虽然我没有等级 在我的eclipse项目中设置),然后将其导入Android Studio。
使用第一种方法时,我遇到了 gradle 和 API 错误,例如:
没有可用于 com.android.support:support-v4:jar 的版本 (我安装了 22 和 23 sdk,它们都没有解决问题)。
错误:(15, 0) Gradle DSL 方法未找到: 'android()' 可能 原因:该项目可能正在使用的 Gradle 版本 不包含方法。摇篮 settings.构建文件可能缺少 Gradle 插件。应用 Gradle 插件
使用项目资源管理器中的第二种方法,我只看到没有 res 文件夹的 Java src 文件。
这是 Gradle 代码:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
}
android {
compileSdkVersion 23
buildToolsVersion '23.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')
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
正确的方法是什么? 我这样做基本上是为了将 Gradle 添加到我的项目中。
谢谢!
【问题讨论】:
-
您是否按照本指南进行迁移? developer.android.com/sdk/installing/migrate.html
-
请提供你的gradle文件的代码
-
嗨@warlock,添加代码。
标签: java android eclipse android-studio android-gradle-plugin