81

I'm trying to create a simple android project with gradle. I work in a computer with Debian GNU/Linux 7 'wheezy'.

I followed the recomendations in Gradle Plugin User Guide - Android Tools Project Site, but it casts an error:

FAILURE: Build failed with an exception.

* Where:
Build file '/home/alex/Proyectos/MyLogin/build.gradle' line: 11

* What went wrong:
A problem occurred evaluating root project 'MyLogin'.
> Could not create plugin of type 'AppPlugin'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.817 secs

I followed the specifications:

  • Gradle 1.9
  • Plugin 0.7
  • SDK 17+ (actually 19)

I also started a project anew, and the results I showed were issued by the command gradle tasks as shown in the documentation.

I also tried gradle 1.10, but the result is the same.

Even this question was not usefull, since it solved with 'upgrading' to gradle 1.6 (I understand that plugin 0.7 requires at least gradle 1.9).

I tried this after failing with the same error in android-studio and IntelliJ Idea.

EDIT: I also tried with new projects in both IDEs, and got the same issue. But what most surprises me is that both IDEs use gradle 1.8 in their wrapped form. I tried to cinfigure both of them to use my local gradle install, but still the same issue.

What am I doing wrong? Is it a bug? How can I avoid the problem?

Please, help me.

EDIT: Here is my build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.+'
    }
}

apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 14
    buildToolsVersion '19.0.1'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
    }
}

sourceCompatibility = 1.6

version = '0.1'

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    //compile project(':core')
}
Community
  • 1
  • 1
aBarocio80
  • 966
  • 1
  • 7
  • 12

11 Answers11

27

Google made a mistake with version 0.7.2 of the Gradle plugin:

Note: 0.7.2 requires Java7. This is a mistake. Use 0.7.3 instead.

Release 0.7.3 re-enables Java6 support. Declaring Gradle 0.7.3 in my build files does indeed resolve this for me.

No one is perfect :)

http://tools.android.com/tech-docs/new-build-system

Ken
  • 30,811
  • 34
  • 116
  • 155
22

Use Gradle 1.9 instead of Gradle 1.10. There is an issue with 1.10 : https://code.google.com/p/android/issues/detail?id=63822

Also answered here:

Can't find org.gradle.api.artifacts.result.ResolvedModuleVersionResult when apply Android plugin in Gradle

Community
  • 1
  • 1
Vasile Jureschi
  • 2,169
  • 2
  • 17
  • 17
19

I got it working using Gradle 1.10 with the Gradle plugin 0.8.0.

// /build.gradle
// Top-level build file where you can add configuration 
// options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.8.+'
    }
}

...

# /gradle/wrapper/gradle-wrapper.properties.
#Sat Feb 01 20:41:29 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
JJD
  • 50,076
  • 60
  • 203
  • 339
  • 3
    Wouldn't it be better to put gradle:0.8.+ instead of gradle:0.8.0? That way you know you're using the latest gradle plugin. – IgorGanapolsky Feb 05 '14 at 15:34
  • 2
    @IgorGanapolsy Not necessarily best. For instance, if at the time you had done gradle:0.7.+ you might well have hit problems that are now well-known. The latest is not always the greatest. – Ken Feb 12 '14 at 08:05
7

If you're using the command line to create the project like so:

android create project -g -v 1.2.2 --target 1 --name rtest --path rtest --activity MainActivity --package com.mydomain.rtest

The project is created to use version 1.2.2 of the android-gradle-plugin, but the project is initialised with gradle 1.12, which isn't compatible.

To fix it, do the following:

  1. Open rtest/gradle/wrapper/gradle-wrapper.properties and set distributionUrl to the release you want; for example: http\://services.gradle.org/distributions/gradle-2.2.1-all.zip (don't forget to escape the colon - yes, that makes me smile too);
  2. Open build.gradle and change runProguard false to minifyEnabled false;
  3. ./gradlew clean && ./gradlew assembleDebug
  4. I also remove the hidden .gradle folder, but I'm not sure if it's necessary

And it all works again.

Jon
  • 9,815
  • 9
  • 46
  • 67
  • thanks! this is the solution that works for me with the latest set of tools. (as of July 2015) – alvi Jul 12 '15 at 08:44
  • Thanks! Google is so shamelessly drinking the Kool-aid from Idea, their command line tools are in a sorry state... – Rick77 Jun 14 '19 at 17:38
2

For those who are using 2.1 version of studio, replace classpath 'com.android.tools.build:gradle:2.1.0-rc1' with classpath 'com.android.tools.build:gradle:2.1.0'. This solved my problem.

Isham
  • 424
  • 4
  • 14
1

If you are attempting to update your Gradle 1.9 project to Gradle 1.10 using

task wrapper(type: Wrapper) {
    gradleVersion = '1.10'
}

and command ./gradlew wrapper you will get the same error as above.

Solution is to install Gradle 1.10 onto your machine and upgrade your project not using the wrapper

gradle wrapper

Blundell
  • 75,855
  • 30
  • 208
  • 233
1

You can also get this error if you update your system gradle and forget to update the Android Studio gradle home.

Eric Woodruff
  • 6,380
  • 3
  • 36
  • 33
0

I got this today when running gradle assembleRelease. I had installed the Ubuntu default of gradle-1.4. This didn't work, so I tried the latest gradle-1.12 and got the same issue.

Downloading and using gradle-1.10 (and matching my gradle-wrapper.properties file to that version) resolved the issue.

This is with Android Studio 0.5.8.

Splaktar
  • 5,506
  • 5
  • 43
  • 74
0

Ok i guess android studio has answer for this to get this bug out using GUI,

I had this error like this... enter image description here

after updating the plugins i was facing another issues while building,

enter image description here

so changes the gradle setting to default as shown in the image, enter image description here

After this build was successful.

m0sa
  • 10,712
  • 4
  • 44
  • 91
Pankaj Nimgade
  • 4,529
  • 3
  • 20
  • 30
0

Go to dependencies and just change the dependencies classpath to classpath 'com.android.tools.build:gradle:2.0.0-beta6' Rest Gradle will take care. Happy coding :)

Abhilash
  • 500
  • 4
  • 13
0

1: Run with scan to see detailed cause. 2: In my case it was pointing to a file in cache(c/user/.gradle/cache/jr-9...). 3: I deleted jr-9 folder and it fixed my issue