No matter what projects I import they never work - Android Studio is always flagging this is not a Gradle build project
.
I select VCS -> GIT
and clone the repo without any problem. I then go through the wizard with no issues (I select create project from existing sources
), creating my code base with a warning, below. When i try to run throws all sorts of errors.
Migrate Project to Gradle? This project does not use the Gradle build
system. We recommend that you migrate to using the Gradle build
system. More Information about migrating to Gradle.
Don't show this message again.
When I go to the link it makes no sense whatever to me, it says to create an arbitrary Gradle file and populate it with my references (I think), which is out of my understanding. I shouldnt have to do this as it says in the repository instructions that it is in fact a Gradle-based project.
The project I am trying to clone is
https://github.com/googlesamples/android-play-location.git
Can anybody tell me specifically how to import and run the following git repo in Android studio for example?
Ok from the start (as i dont know what other way works)
- Go to Git master page (it has 'download to zip' or 'clone to desktop' button). use https://github.com/googlesamples/android-play-location as a test master page if you like to ensure you have no other issues i did not.
- Click 'download zip'
- Unzip the project
- Close the current project in Android Studio -> File/Close Projects
- A popup screen like this will appear, choose Import Project (Eclipse ADT, Gradle etc.)
- You will be asked to select the project, select your unzipped project within the master folder, eg basicLocation
- Select 'create project from existing resources' default
- dont change project name (may cause issues)
- Next through 'import project -> directories'
- Next through project -> libraries
- Next Through import projects -> modules and module dependencies
- Next through import project ->SDK
- Next through import project ->manifest.xmls
- Android Studio starts. Ensure the configurations dropdown has a project in it called 'app' app
- Select 'sync Gradle' icon (green circle)
- May get language warning, ignore or accept restart, doesnt matter
At bottom it should now say 'Gradle executing tasks' after which it will run on device or emulator :)
Short answer: File > Open > the build.gradle file you just cloned with the repo
I just wanted to add this, because I had the same problem, and even if Fearghal´s answer and comments pointed me in the right direction, I think he may have added unnecesary extra steps, i.e. Download as ZIP, Close current project, etc.
Simply put, you VCS > Git Clone, and then open the build.gradle file. That´s it
This can happen for many reasons. I typically see it when I move the directory. The easiest way I have found is to close the project and then reopen it using "Import project (Gradle, Eclipse, ADT, etc.) menu item then selecting the folder. This will force it to reimport the project and fix any metadata/configs.
What worked for me was
On Android Studio
Open the settings.gradle file
include your project
include ':myproject'
Well, as Android Studio correctly says, https://github.com/googlesamples/android-play-location is not a Gradle project.
Any subdirectory of that repository is however.
They are different projects.
So clone that repository and import one of its subdirectory in Gradle.