【发布时间】:2015-07-29 17:30:50
【问题描述】:
我从 Eclipse 生成了一个 Android 项目的 Gradle 文件,以便继续在 Android Studio 中处理该项目。然后我导入 Gradle 文件在 Android Studio 中打开项目,但是非常令人困惑的是它无法构建项目,显示以下消息。
Error:SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
我一直在 Android Studio 中处理其他 Android 项目,在这个问题上没有任何问题,所以我变得太困惑了。我也搜索了有关同一问题的问题,但似乎没有一个明确提出解决方案。
为了让你更好地理解,我给你展示了一些与构建项目相关的东西。
1. build.gradle
apply plugin: 'com.android.application'
和
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:22.2.0'
}
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
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')
}
}
2。 local.properties
sdk.dir=/Users/marshall/android-sdks
Android SDK 已按上述方向正确安装。我现在该怎么办?
【问题讨论】:
标签: android eclipse gradle android-gradle-plugin