178

today I just imported a sample app from Android SDK as a module in my project (analytics) and suddenly I got this gradle error when I try to sync it: Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE envrinment variable to...

This is my app gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"
    defaultConfig {
        applicationId "xxx.xxxxxx.xxxxx"
        versionCode 1
        versionName '1'
        minSdkVersion 9
        targetSdkVersion 22
        versionCode 1
        versionName '1'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.android.support:recyclerview-v7:21.0.0'
    compile 'com.android.support:cardview-v7:21.0.0'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    testCompile 'junit:junit:4.12'
    compile project(':volley')
}

Do you have any idea of which may be the cause (I'm using the plugin version 1.1.0-rc1 and the gradle version 2.2 and Android Studio version 1.1.0)?

EDIT:

This is my top build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0-rc1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
Kalle Richter
  • 8,008
  • 26
  • 77
  • 177
Mario Norato
  • 1,871
  • 2
  • 12
  • 12
  • 4
    You need Gradle 2.2.1 for Android Studio 1.1.0. The Gradle for Android plugin 1.1 is now available, so you should no longer need the `-rc1`. – CommonsWare Mar 15 '15 at 17:41
  • First of all thanks for your immediate answer, I will try to change the settings of the project and I will post the results here. Thanks again! :-) – Mario Norato Mar 15 '15 at 17:45
  • 1
    It worked! I just deleted the "-rc1" part from the classpath. Now it synched. Thanks again! PS I'm not very good in using stackoverflow, how do I upvote your answer or mark it as the correct one? – Mario Norato Mar 15 '15 at 17:51
  • 1
    you can always find **latest gradle version** here http://developer.android.com/tools/revisions/gradle-plugin.html – Bharatesh May 12 '16 at 09:20
  • How rude for Android Studio. If something is automatic-generated from gui, it must NEVER need the programmer's assistance. – Chameleon May 28 '16 at 19:02
  • Gosh - would it be too hard for whoever issued the message to say WHICH plugin is too old and which minimum version would be acceptable? There are shades of 'The program specified is not recognised as an executable or a binary' or 'The file is in use by another program' here. – android.weasel May 11 '17 at 11:12

17 Answers17

133

Just like CommonsWare suggested, make sure you have Gradle 2.2.1+ (the latest is 2.3).

Make sure you upgrade your Android Studio but here are the "plugins" that need to be updated:

Top build.gradle:

Change:

classpath 'com.android.tools.build:gradle:1.1.0-rc1'

To:

classpath 'com.android.tools.build:gradle:1.1.3' // latest 1.5.0

App build.gradle:

Change:

compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.0'

To:

compile 'com.android.support:recyclerview-v7:22.0.0' // latest 23.1.1
compile 'com.android.support:cardview-v7:22.0.0' // latest 23.1.1

Gradle: https://gradle.org/downloads

Always check the Android SDK Manager for the latest revisions:

Android Build Tools Plugin: http://tools.android.com/tech-docs/new-build-system

Android Support Libraries: http://developer.android.com/tools/support-library/features.html

To view the latest plugin releases, view the Bintray Jcenter page directly: https://bintray.com/android/android-tools/com.android.tools.build.gradle/view.

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
  • Ok, after reading Commonsware answer I just took away the -rc1 part of the classpath and after indexing now it seems to work fine (ouch I lost almost 2 hours not to bother any of you here in stack overflow :-) ), now I'll try to update the plugin as you suggest. :-) Thanks again. – Mario Norato Mar 15 '15 at 17:56
  • 1
    @MarioNorato No problem, I'll post the links to where you can find the latest version all the time. Also, Android studio should warn you of newer version if you keep the Android SDK manager updated. – Jared Burrows Mar 15 '15 at 17:57
  • had the same issue. moving the plugin from 1.4.+ to 1.3.+ did the trick. also i'm using gradle 2.8 and have a script that always downloads the latest version, apparently it has it's price... – codeScriber Nov 16 '15 at 07:27
  • 18
    I had to go to `https://jcenter.bintray.com/com/android/tools/build/gradle/` to figure out what the latest version of gradle was. Updating my top gradle file with the latest available version from that URL fixed the problem. Your solution did not give me enough information to find this! – exhuma Jan 02 '16 at 14:14
  • @JaredBurrows I'm new to Android dev. I was wary to edit your answer with something potentially incorrect. I just wanted to let you know that I was unable to solve the issue by your answer alone. – exhuma Jan 02 '16 at 18:32
  • 1
    It would be worth linking to this location (IMHO, it is better then the Gradle website) - which has the latest Gradle release version listed: http://developer.android.com/tools/revisions/gradle-plugin.html – Booger Apr 09 '16 at 01:15
  • @JaredBurrows his (exhuma) comment is most helpful one and just have saved me hours of head banging. – Ivan Marjanovic Apr 19 '16 at 08:32
  • @IvanMarjanovic 1. That is apart of my answer 2. I post that in my other answer here: http://stackoverflow.com/a/25232725/950427 – Jared Burrows Apr 19 '16 at 16:01
46

Solution (Updated: 24-may-2016): Change build.gradle (project)

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:X.X.X-lastVersionGradle'
    classpath 'com.google.gms:google-services:X.X.X-lastVersionGServices' // If use google-services

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

X.X.X-lastVersionGradle: For example: 2.1.0

X.X.X-lastVersionGServices: For example: 3.0.0 (support Firebase Analytics)

Note: if you're using the google-services plugin has to be the same version (if there)

Warning!! -> 2.2.0-alpha throws Unsupported major.minor version 52.0 if you don't use java JDK 8u91 and NetBeans 8.1

SergioLucas
  • 1,094
  • 8
  • 16
32

As a side note, I have been getting the same error in completely unrelated situation - after my system clock year setting has been changed (i.e. 2015 -> 2016); changing the clock back to the correct one solved the issue.

Note 1: I'm posting this mainly because I had the exactly same error message, but the working solution proven to be different than just updating the plugin's version (as posted by Jared Burrows).

Note 2: using

classpath 'com.android.tools.build:gradle:+'

can make the plugin version default to newest one. Bear in mind that your build may break on API changes (and is, for that very reason, discouraged by Android API docs), so use this at your own risk only if you're constantly updating the version anyway.

  • 4
    The Intellij/Android Studio will warn you not to do this, as you should know what version you are using. – Jared Burrows Apr 08 '15 at 21:06
  • 1
    @JaredBurrows I know what version I'm using - the newest one. I see no particular reason to bind yourself to a particular release, and manually updating the version each time a new release is done is hardly a more sensible option than using `+` version IMO. Warnings are emitted to help with programming, if they were referring to hard, unbendable rules they wouldn't have been warnings but errors in the first place. Still, you made a completely valid point, I've included that info in my post. –  Apr 08 '15 at 21:31
  • 1
    using the '+' operator produces unpredictable builds and should always be avoided. This is a dangerous answer. – Andrew Grosner Oct 05 '15 at 13:07
  • @agrosner see [my comment](http://stackoverflow.com/questions/29063968/plugin-is-too-old-please-update-to-a-more-recent-version-or-set-android-daily/29459402?noredirect=1#comment47205783_29459402) above for rationale. True, it should be avoided in final relases and in serious production code, but there is no real downside to using it in continuous development of small applications. Rephrased to make that more apparent. As a side note, that info was given as a *possible solution to real problem*, not as a *best practice* - and it's not the answer's here - the answer is to check the clock. –  Oct 05 '15 at 17:36
  • Well... I'm having this problem today, and it really is 2016 now... Any chance this might be related? Also, is there a way to fix this without changing the clock? I'm currently getting my feet wet with Android and the build environment. It's all still new to me and I'm kind of lost with this error :( – exhuma Jan 02 '16 at 14:06
  • Read the caution here: https://developer.android.com/studio/releases/gradle-plugin.html "Caution: You should not use dynamic dependencies in version numbers, such as 'com.android.tools.build:gradle:2.+'. Using this feature can cause unexpected version updates and difficulty resolving version differences." – weston Oct 14 '16 at 17:47
  • @weston I've already stated, quote "Note that your build may break on API changes, so use this only if you're constantly updating the version anyway." In programming, there are *should/n't*s, and there are **must/n't**s (explained in e.g. C++ standards). [You shouldn't use goto.](http://programmers.stackexchange.com/questions/566/is-using-goto-ever-worthwhile) [You shouldn't break encapsulation](http://www.koonsolo.com/news/object-oriented-programming-doesnt-need-encapsulation/) etc. OTOH, [You musn't use voodoo in your programming](http://stackoverflow.com/questions/11782951). –  Oct 14 '16 at 22:21
  • @weston it was made small print [exactly for that reason](https://en.wikipedia.org/wiki/Fine_print) - it doesn't constitute the answer itself and was added as a trivia. –  Oct 16 '16 at 14:00
29

Just in case someone is struggling with this, in my case I'm using Gradle 1.4 beta 1 and I NEED to keep it. So in order to make Android Studio works go to the terminal and run this:

launchctl setenv ANDROID_DAILY_OVERRIDE <your-value-on-error-message>

Restart Android Studio and the project will build again.

Kudos to UPDATE 2 here: https://emmanuelbernard.com/blog/2012/05/09/setting-global-variables-intellij/

Felipe Duarte
  • 1,079
  • 14
  • 20
15

You can always check the latest gradle plugin version here: https://bintray.com/android/android-tools/com.android.tools.build.gradle

So as of today you should use:

classpath 'com.android.tools.build:gradle:2.2.2'

accordingly.

IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147
9

Replace your class path with something ambiguous like this. Its a solution and it works but it may not be a good solution.

classpath 'com.android.tools.build:gradle:+'

The best way is replacing the + with the latest version of gradle

Victor Mwenda
  • 1,677
  • 17
  • 16
  • Well, only if you really want to use the alpha or beta versions, too. – JacksOnF1re May 24 '16 at 22:32
  • Read the caution here: https://developer.android.com/studio/releases/gradle-plugin.html "Caution: You should not use dynamic dependencies in version numbers, such as 'com.android.tools.build:gradle:2.+'. Using this feature can cause unexpected version updates and difficulty resolving version differences." – weston Oct 14 '16 at 17:46
6

Check the latest version of Gradle Plugin Here:

[ ![Download] 1]2

You should change this in dependencies of app settings

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:[PLACE VERSION CODE HERE]'
    
}

}

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Dinesh Sunny
  • 4,663
  • 3
  • 30
  • 29
1

I'm using Android Data Binding and I have the same problem today.

To solve it, change:

classpath "com.android.databinding:dataBinder:1.0-rc0"

To:

classpath "com.android.databinding:dataBinder:1.0-rc1"

1.0-rc0 still could be found on jcenter now, I don't know why it couldn't be use.

Peter Zhao
  • 7,456
  • 3
  • 21
  • 22
1

I got a way which finally resolve this 1. check your calsspath in the top build.gradle,e.g mine is classpath 'com.android.tools.build:gradle:2.1.0-alpha3' then go to https://jcenter.bintray.com/com/android/tools/build/gradle/ find a release which is newer than yours,here I choose 2.1.0-beta3 change classpath to below, then launch the build. classpath 'com.android.tools.build:gradle:2.1.0-beta3'

hugo
  • 45
  • 2
1

If you want to continue to use the newest development versions then this problem can reoccur each time your version is far enough out of date.

I've been keeping an up-to-date list of the most current development versions as well as the stable version on my answer to this similar question, so that I can fix it each time I get a new warning:

Android Studio 2.0 - Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE

Community
  • 1
  • 1
Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124
0

The solution of removing the '-rcX' part works. I wanted to provide some more detail on why the error is happening. The issue is with https://android.googlesource.com/platform/tools/base/+/master/build-system/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.java#230

There is a default 40 days 'retirement age' for plugins that don't have a version or contain 'rc', 'alpha', or 'beta'.

ashoykh
  • 111
  • 1
  • 2
0

In the past months, I used a "preview" version of Android Studio. I tried to switch back to the "stable" releases for the software updates but it wasn't enough and I got this famous error you talk of.

Uninstalling my Android Studio 2.2.preview and installing latest stable Android Studio (2.1) fixed it for me :)

Guillaume Gendre
  • 2,504
  • 28
  • 17
0

Go for stable version or gradle in app level gradle file in my case it was
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'

I changed it with

classpath 'com.android.tools.build:gradle:2.1.2'

0

the output is from NonFinalPluginExpiry.java

example 2.4.0-alpha7

https://github.com/c3ph3us/android-gradle-plugin-source-codes/blob/master/gradle-2.4.0-alpha7-sources/com/android/build/gradle/internal/NonFinalPluginExpiry.java

if someone want to use plugin and dont want to do a daily google shi..

either need to:

  1. recompile plugin
  2. replace "Plugin-Version" in manifest
  3. make a automation script to generate env var and set it daily

         MessageDigest crypt = MessageDigest.getInstance("SHA-1");
         crypt.reset();
         crypt.update(String.format(
                         "%1$s:%2$s:%3$s",
                            now.getYear(),
                            now.getMonthValue() -1,
                            now.getDayOfMonth())
                            .getBytes("utf8"));
        String overrideValue = new BigInteger(1, crypt.digest()).toString(16);
    

EXAMPLE APP IN JAVA (sources + JAR):

  1. FOR GENERATE ADO - for ALL OS'es WITH JVM
  2. SET ENV for LINUX

https://github.com/c3ph3us/ado

https://github.com/c3ph3us/ado/releases

example bash function to export env and start idea / or studio:

// eval export & start idea :) 
function sti() {
    export `java -jar AndroidDailyOverride.jar p`
    idea.sh
}
ceph3us
  • 7,326
  • 3
  • 36
  • 43
0

This is android's way of telling you to upgrade gradle to the most recent version. You can do two things-

  1. Upgrade to the newer version of gradle. You may face new errors after the upgrade (eg, if you are upgrading to 4.1, you will have to adapt to new syntax - "compile" is no longer valid, use "implementation").
  2. Update your ANDROID_DAILY_OVERRIDE variable to the value given. Go to Computer -> Properties -> Advanced System Settings -> Environment Variables, and create a new variable or update value of existing ANDROID_DAILY_OVERRIDE. As the name suggests, this value is only valid for one day and next day you will again have to override the variable.
kshubham07
  • 341
  • 1
  • 3
  • 15
-1

set Environment variable ANDROID_DAILY_OVERRIDE to same value Example - b9471da4f76e0d1a88d41a072922b1e0c257745c

this works for me.

Virendra
  • 43
  • 3
-1

You should upgrade the version of gradle. for example: com.android.build.gradle 1.3.0

this issue occurs when version of the gradle is changed.