当我试图将一个项目导入到Android Studio 0.2.9时,我遇到了以下错误:
Could not execute build using Gradle distribution
'http://services.gradle.org/distributions-snapshots/
gradle-1.8-20130830160653+0000-bin.zip'.
A problem occurred configuring project ':library'.
A problem occurred configuring project ':library'.
Failed to notify project evaluation listener.
Neither path nor baseDir may be null or empty
string. path='' basedir='<projects folder>/
drag-sort-listview/library'
Consult IDE log for more details (Help | Show Log)
该项目最初是一个Maven项目 (1). 我在Eclipse ADT中打开它,并按照(2)的说明生成了一个 /librabry/build.gradle
文件。
Eclipse ADT生成的build.gradle
文件如下:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 7
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['']
resources.srcDirs = ['']
aidl.srcDirs = ['']
renderscript.srcDirs = ['']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
我不得不修改第6行为:
classpath 'com.android.tools.build:gradle:0.4'
到
classpath 'com.android.tools.build:gradle:0.5+'
我希望您可以帮助使Android Studio停止显示版本不匹配的提示。我还添加了一个包含/settings.gradle
文件的项目。
include ':library'
同时还需要一个/local.properties
文件,其中包含以下内容:
# This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/Applications/Android Studio.app/sdk
我尝试通过在“文件|导入项目...”对话框中选择/settings.gradle
文件来导入它。我已经检查了“使用自动导入”并在对话框(3)中选择了“使用带验证的gradle wrapper”选项。完整的idea.log
条目可以在(4)中查看。非常感谢您的任何帮助。