I'm trying to restore a project inside Android Studio. I've got a backup of the code (an export of the git repository). When I click on open "an existing android studio project" it asks for the local gradle distibution but I don't know what is. I tried with the folder in my_android_studio_path/plugins/gradle but it doesn't work, it tells me "The project is using an unsupported version of Gradle.". What I need to do?
1 Answer
The "open an existing Android Studio project" seems to only work for a project that has already been opened before and therefore has all of the metadata generated from the Gradle build files (e.g., the .iml
file, the .idea/
directory). That metadata should not be in version control, as it is rebuilt from the Gradle build files (hence, the frequent need to "sync" the files).
So, if you have a project from version control, that has build.gradle
and kin but not the .iml
and .idea/
files, use "import a non-Android Studio project". It will detect the existence of the Gradle build files and assume that you know what you are doing (whether you really do know what you are doing is left as an exercise for the reader). It just sets up the metadata.
However, it helps if your Android Studio project, in version control, has the gradle/wrapper/gradle-wrapper.properties
file, with a distributionUrl
value that points to the Gradle that you want to use. I forget the exact behavior if that is missing.
gradle/wrapper/gradle-wrapper.properties
file, so Studio knows what version of Gradle to use.