Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 827
joe_deniable Avatar asked May 16 '13 13:05

joe_deniable


2 Answers

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 - i.e. 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.

like image 177
Mark Allison Avatar answered Nov 15 '22 01:11

Mark Allison


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 (e.g. gradlew.bat, settings.gradle).

like image 22
joe_deniable Avatar answered Nov 15 '22 00:11

joe_deniable