Gradle build errors with Android Studio

When I try to build my project in Android Studio I get the following error, using the gradle plugin provided with the download (v 1.6):

The specified Gradle installation is not supported by this tooling API version (1.6, protocol version 4)

When I downgrade to gradle 1.3, 1.4 or 1.5, I get this error:

Gradle: : java.lang.ClassNotFoundException: org.gradle.tooling.provider.model.ToolingModelBuilderRegistry

The project was originally created in Eclipse, the exported using the build gradle file option, then imported into Android Studio.

Does anyone know what I can do to fix these issues? Many thanks.


I had a similar problem and I believe that it was caused by having multiple versions of gradle on my machine. The solution I found was to use the script that Android Studio creates in your project folder (either gradlew (MacOs/Unix) or gradlew.bat (Windows)):

./gradlew assemble

This causes the correct version of gradle to be run - ie the version that was shipped with Android Studio.

I haven't tried creating a project within Eclipse, so I'm not sure if these scripts are created when creating your project in that way.


I think the problem is with the way Eclipse 22 exports the project. In the end the way I got my project transferred over was to create a new project in Android Studio and copy over the files from my Eclipse project into the appropriate directories in the new project.

The directory structure of projects in Android Studio is very different to the structure in Eclipse, and there are several files created when you start a new project which you don't get when importing a project from Eclipse (eg gradlew.bat, settings.gradle).


I also had this problem which can indeed be worked around with Mark's suggestion of using ./gradlew assemble.

However, this does not help you run Make Project from within Android Studio.

To do that, I had to go to Preferences / Gradle / Use local gradle distribution

and select any random (but NOT gradle) folder inside the project folder.

You might notice that this is marked as an invalid location, but you can ignore that, it seems...

Not a great solution, but it works.

链接地址: http://www.djcxy.com/p/13534.html

上一篇: 用于服务器到服务器通信的Node.js

下一篇: Android Studio的Gradle构建错误