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()
    }
}
6
  • 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. Commented Mar 15, 2015 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! :-) Commented Mar 15, 2015 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? Commented Mar 15, 2015 at 17:51
  • 1
    you can always find latest gradle version here developer.android.com/tools/revisions/gradle-plugin.html
    – Bharatesh
    Commented May 12, 2016 at 9:20
  • How rude for Android Studio. If something is automatic-generated from gui, it must NEVER need the programmer's assistance.
    – Chameleon
    Commented May 28, 2016 at 19:02

17 Answers 17

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.

8
  • 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. Commented Mar 15, 2015 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. Commented Mar 15, 2015 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... Commented Nov 16, 2015 at 7: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
    Commented Jan 2, 2016 at 14:14
  • 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: developer.android.com/tools/revisions/gradle-plugin.html
    – Booger
    Commented Apr 9, 2016 at 1:15
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

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

8
  • 4
    The Intellij/Android Studio will warn you not to do this, as you should know what version you are using. Commented Apr 8, 2015 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.
    – user719662
    Commented Apr 8, 2015 at 21:31
  • 1
    using the '+' operator produces unpredictable builds and should always be avoided. This is a dangerous answer. Commented Oct 5, 2015 at 13:07
  • @agrosner see my comment 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.
    – user719662
    Commented Oct 5, 2015 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
    Commented Jan 2, 2016 at 14:06
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/

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.

0
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

2
  • Well, only if you really want to use the alpha or beta versions, too. Commented May 24, 2016 at 22:32
  • Read the caution here: 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
    Commented Oct 14, 2016 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]'
    
}

}

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

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'

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

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

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

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
}
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.
-1

set Environment variable ANDROID_DAILY_OVERRIDE to same value Example - b9471da4f76e0d1a88d41a072922b1e0c257745c

this works for me.

3
  • And where this variable located?? Commented Sep 19, 2015 at 14:23
  • Where I must set ANDROID_DAILY_OVERRIDE? Commented Oct 5, 2015 at 7:06
  • 1
    @MiguelAngel_LV, AndriodNewbie, google how to export environment variable in your operating system. This is an OS feature Commented Oct 8, 2015 at 12:59
-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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.