When working with Android Studio 2.0, Gradle may occasionally decide to stop building your application, and throw you the following error instead:
Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to “XXXX”.
This is due to the fact that AS 2.0 uses an alpha version of the Android plugin for Gradle. As new versions of the plugin get released, so may older ones become incompatible. Therefore, it is recommended that one changes the version of the Android plugin manually, and tests if everything still works as it should.
How to solve the problem
One possibility is to simply follow the instructions and set an environment variable with the specified value. On OSX this looks as follows:
launchctl setenv ANDROID_DAILY_OVERRIDE
Afterwards, clean the project, restart AS, and build again.
If you want to have precise control over the version of the Android plugin for Gradle, which AS is currently using, open the base
build.gradle file and locate the classpath to the Android plugin. In my case, this was:
Check Bintray for the latest version of the plugin (2.0.0.-alpha3 at the time of this writing) and update correspondingly. Do not forget to sync your Gradle changes, clean, and rebuild the project, in order to to avoid issues with temporary files or cached data.