无法将Eclipse项目导入到Android Studio

时间:2023-01-17 18:25:14

Whenever I try to import my Eclipse project to Android Studio I get the following error :

每当我尝试将Eclipse项目导入到Android Studio时,我都会得到以下错误:

You are using an old, unsupported version of Gradle. Please use version 1.8 or greater. Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)

您正在使用一个旧的、不受支持的Gradle版本。请使用1.8版或以上版本。请在项目的等级设置或项目的等级包装(如果适用的话)中指出支持的等级版本。

Consult IDE log for more details (Help | Show Log)

查阅IDE日志了解更多细节(帮助|显示日志)

Im using Android Studio 0.3 and Ubuntu, I also tried it on a Windows 8 box with fresh install but getting the same error. I'm using default gradle wrapper and I tried checking and unchecking auto import option. Is this a bug? How can I get around it. How do I update gradle to 1.8 or check the current gradle version?

我使用的是Android Studio 0.3和Ubuntu,我也在Windows 8系统上试用过,新安装了,但也有同样的错误。我使用的是默认的等级包装,我尝试了检查和取消检查自动导入选项。这是一个错误吗?我怎么能避开它呢。如何更新等级为1.8或检查当前等级版本?

3 个解决方案

#1


66  

I had to edit the gradle wrapper settings in gradle/wrapper/gradle-wrapper.properties and change gradle version to 1.9.

我必须在level /wrapper/gradle-wrapper中编辑gradle wrapper设置。属性并将等级版本更改为1.9。

./gradle/wrapper/gradle-wrapper.properties :

。/它/包装/ gradle-wrapper。属性:

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip

I had to change gradle-1.6-bin.zip to gradle-1.9-all.zip. I guess the old ADT plugin from eclipse which generates this file still uses the old URL.

我必须换1.6年级。gradle - 1.9 all.zip zip。我猜eclipse中生成这个文件的旧ADT插件仍然使用旧的URL。

Then I had to create a local.properties in project root and set correct SDK dir in it.

然后我必须创建一个本地的。项目根中的属性,并在其中设置正确的SDK dir。

./local.properties

。/ local.properties

sdk.dir=/home/user/pathtosdk

Did that and imported using default gradle wrapper and voila! The project imported without any problem.

这样做了,然后使用默认的等级包装器导入,瞧!项目导入没有任何问题。

Notes: This also fixes the issue with org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle distribution 'services.gradle.org/distributions/gradle-1.6-bin.zip';.: Could not execute build using Gradle distribution 'services.gradle.org/distributions/gradle-1.6-bin.zip'; You must also make sure that in the file ./build.gradle, com.android.tools.build:gradle:0.5.+ should be changed to com.android.tools.build:gradle:0.7.+.

注意:这也解决了org.gradle.tool存在的问题。GradleConnectionException:不能使用Gradle distribution 'services执行构建。gradle.org/distributions/gradle 1.6-bin.zip';:不能使用Gradle distribution 'services执行构建。您还必须确保在文件中。/build。gradle,com.android.tools.build:gradle:0.5。+应该改成com.android.tools.build:gradle:0.7.+

If you are still experiencing problems with import, open up the project root in command line and run ./gradlew or gradlew.bat according to your os. You'll be getting errors with more debug info and maybe tips on how to solve them.

如果您仍然遇到导入问题,请打开命令行中的项目根并运行。/gradlew或gradlew。根据你的操作系统。您将会得到更多的调试信息和如何解决它们的提示。

#2


6  

For me line in build.gradle file

对我来说,在构建中。gradle文件

dependencies {
    classpath 'com.android.tools.build:gradle:0.5.+'
}

to

dependencies {
    classpath 'com.android.tools.build:gradle:0.6.+'
}

Also needed to be updated to import correctly in Android Studio.

还需要更新以在Android Studio中正确导入。

#3


3  

I had exactly the same problem. I solved this issue. Download latest Gradle manually and unpack it, then when you import gradle file in Android studio choose "Use local gradle distribution" and select the folder where you unpacked gradle. By doing this you will be able to import project to Android studio.

我也有同样的问题。我解决了这个问题。请手动下载最新的Gradle,然后在Android studio中导入Gradle文件时,选择“使用local Gradle distribution”,然后选择您未打包的Gradle文件夹。通过这样做,您将能够将项目导入到Android studio。

#1


66  

I had to edit the gradle wrapper settings in gradle/wrapper/gradle-wrapper.properties and change gradle version to 1.9.

我必须在level /wrapper/gradle-wrapper中编辑gradle wrapper设置。属性并将等级版本更改为1.9。

./gradle/wrapper/gradle-wrapper.properties :

。/它/包装/ gradle-wrapper。属性:

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip

I had to change gradle-1.6-bin.zip to gradle-1.9-all.zip. I guess the old ADT plugin from eclipse which generates this file still uses the old URL.

我必须换1.6年级。gradle - 1.9 all.zip zip。我猜eclipse中生成这个文件的旧ADT插件仍然使用旧的URL。

Then I had to create a local.properties in project root and set correct SDK dir in it.

然后我必须创建一个本地的。项目根中的属性,并在其中设置正确的SDK dir。

./local.properties

。/ local.properties

sdk.dir=/home/user/pathtosdk

Did that and imported using default gradle wrapper and voila! The project imported without any problem.

这样做了,然后使用默认的等级包装器导入,瞧!项目导入没有任何问题。

Notes: This also fixes the issue with org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle distribution 'services.gradle.org/distributions/gradle-1.6-bin.zip';.: Could not execute build using Gradle distribution 'services.gradle.org/distributions/gradle-1.6-bin.zip'; You must also make sure that in the file ./build.gradle, com.android.tools.build:gradle:0.5.+ should be changed to com.android.tools.build:gradle:0.7.+.

注意:这也解决了org.gradle.tool存在的问题。GradleConnectionException:不能使用Gradle distribution 'services执行构建。gradle.org/distributions/gradle 1.6-bin.zip';:不能使用Gradle distribution 'services执行构建。您还必须确保在文件中。/build。gradle,com.android.tools.build:gradle:0.5。+应该改成com.android.tools.build:gradle:0.7.+

If you are still experiencing problems with import, open up the project root in command line and run ./gradlew or gradlew.bat according to your os. You'll be getting errors with more debug info and maybe tips on how to solve them.

如果您仍然遇到导入问题,请打开命令行中的项目根并运行。/gradlew或gradlew。根据你的操作系统。您将会得到更多的调试信息和如何解决它们的提示。

#2


6  

For me line in build.gradle file

对我来说,在构建中。gradle文件

dependencies {
    classpath 'com.android.tools.build:gradle:0.5.+'
}

to

dependencies {
    classpath 'com.android.tools.build:gradle:0.6.+'
}

Also needed to be updated to import correctly in Android Studio.

还需要更新以在Android Studio中正确导入。

#3


3  

I had exactly the same problem. I solved this issue. Download latest Gradle manually and unpack it, then when you import gradle file in Android studio choose "Use local gradle distribution" and select the folder where you unpacked gradle. By doing this you will be able to import project to Android studio.

我也有同样的问题。我解决了这个问题。请手动下载最新的Gradle,然后在Android studio中导入Gradle文件时,选择“使用local Gradle distribution”,然后选择您未打包的Gradle文件夹。通过这样做,您将能够将项目导入到Android studio。