Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
686 views
in Technique[技术] by (71.8m points)

gradle - Unable to import Eclipse project to Android Studio

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

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.)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

#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.

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

./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.+.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...