我已经和Android Studio斗争了两天了,因为我不能像我所做的那样在IDE.Here中导入2个eclipse项目。
这些项目是两个Eclipse项目,我通过执行FILE > export > Generate build.gradle files来导出它们。
当我尝试在Android Studio中导入项目时,出现以下错误:
Failed to refresh Gradle project 'SourceFiles'
You are using Gradle version 1.11, which is not supported. Please use version 1.9.
Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)
Fix Gradle wrapper and re-import project Gradle settings如你所见,我使用的是gradle的最新发行版(版本1.11),它仍然不能工作。有人能告诉我在Android Studio中导入这些项目的正确方法吗?
我在Linux OpenSuse version13.1 Android Studio : 0.4.2 Java : 1.7上
EDIT My project由目录Sourcefiles组成,其中包含两个子目录Skeletons和Testcase。Skeletons包含源文件,TestCase包含与Skeletons中的项目相关联的测试用例。
以下是由Eclipse生成的SourceFiles级别的build.gradle:
task wrapper(type: Wrapper) {
gradleVersion = '1.9'
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}在骨架层级中:
android {
compileSdkVersion 18
buildToolsVersion "19.0.2"
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')
}
}在测试用例级别目录中:
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':Skeletons:FragmentsLab')
}
android {
compileSdkVersion 18
buildToolsVersion "19.0.2"
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')
}
}我也不得不承认我在gradle还是个菜鸟。我还更新了金丝雀频道中的最新版本Android Studio,并在我的项目中引用了gradle的1.9版本。任何帮助都将不胜感激。
我想使用Eclipse IDE,但它总是崩溃。
发布于 2014-02-22 19:22:47
最新的gradle版本有很多问题,你真的应该尝试使用旧的版本,1.9就可以了。将此命令添加到根build.gradle中,并从控制台运行gradle wrapper:
task wrapper(type: Wrapper) {
gradleVersion = '1.9'
}它应该会在你的项目中创建一个gradle路径。之后,在命令行中使用gradlew而不是gradle,或者在Android Studio中创建项目时选择"customizable gradle wrapper“选项。
如果您还会遇到版本问题,请在gradle\wrapper\gradle-wrapper.properties中更改distributionUrl的值
https://stackoverflow.com/questions/21953425
复制相似问题