If you created a project with an old version of Android Studio, it’s sometimes impossible to build it after updating Android Studio (or if you don’t have the right version). Generally it’s a Gradle version problem.
This link shows the compatibility between Android Studio release , the Gradle plugin release and Gradle release :
1 – Take the example of a project created with Android 0.8.4 and we’ll build it with Android 1.1.0.
2 – Do a copy of the project in Windows Explorer
3 – Build it, and there Android Studio said that we don’t have the correct version of Android Build Tools.
Just click on the first link. You will fall on this screen:
Check Accept and click Next. The installation is done.
4 – Try to build the project. Android Studio informs us about an error in our build.gradle file.
Sometimes Android Studio suggests the link below, sometimes it does some actions alone. This link may help you: http://tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0
Generally there is nothing complicated, just change a few lines of your build.gradle file.
In our example, Android Studio has not changed all by itself: a property has changed in the build.gradle file, as shown in the official documentation:
- minifyEnabled replaces runProguard
The documentation says:
You just have to replace the line:
5 – We try to build the project and there is a new problem: now our Android Build Tools is not compatible with the new gradle release.
Just click on the link provided by Android Studio, Android Studio install the right Build Tools alone.
6 – New attempt to build and… A flood of errors! It’s normal ! It’s due to the new AppCompat v21 coming with Android Lollipop and Material Design.
In build.gradle file, replace:
Build your project and… Tadaaaa!
This post is also available in 2 - Lire cette page en français.