I have yet to find a good solution within Android Studio, but this has worked for me on several projects:
- Close the project in Android Studio (so it doesn’t open the project automatically in later steps) and then close Android Studio
- Clean the project (delete the “.idea” and “build” folders, .iml files, etc.) so you only have the source files remaining
- Set up gradle by adding the appropriate settings.gradle and build.gradle files (test your setup using the command line)
- Open Android Studio and choose “Import project” and choose to use Gradle as the external model
- Pick your settings.gradle file as the Gradle project
- [Optional] Set your “Gradle home” folder (so the text turns black instead of gray). Earlier versions of Android Studio caused problems for me if I didn’t do this. Make sure you use Gradle 0.1.10 or newer (earlier versions do not work with the current Gradle build tools).
Also, remember to use the latest version of the Gradle build tools. If you want, you can setup Gradle to use the most recent version like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}