Android Studio does not recognize Gradle projects

No matter what projects I import, they never work - Android Studio is always tagged with this is not a Gradle build project .

I select VCS -> GIT and clone the repo without any problems. Then I go through the wizard without any problems (I select create project from existing sources ), creating my code base with the warning below. When I try to run all kinds of errors.

Transfer project to Gradle? This project does not use the construction of the Gradle system. We recommend that you switch to using the Gradle build system. Learn more about migrating to Gradle.

Do not show this message again.

When I go to the link, it makes no sense to me, he says to create an arbitrary Gradle file and fill it with my links (I think), which is not in my power. I should not do this, as in the instructions of the repository he says that this is actually a Gradle-based project.

The project I'm trying to clone is https://github.com/googlesamples/android-play-location.git

Can someone tell me how to import and run the following git repo in android studio for example?

+3
android android-studio gradle
source share
6 answers

Good from the start (since I don't know how the other way works)

  • Go to the Git homepage (it has a “upload to zip” or “clone to desktop” button). use https://github.com/googlesamples/android-play-location as the main test page, if you want to have no other problems, I didn’t.
  • Click "download zip"
  • Unzip the project
  • Close the current project in Android Studio -> File / Close Projects
  • A popup window similar to this will appear, select "Import Project" (Eclipse ADT, Gradle, etc.).
  • You will be asked to select a project, select the unpacked project in the main folder, for example basicLocation
  • Select "create project from existing resources" by default
  • Do not change the project name (may cause problems)
  • Further through 'import project -> directories'
  • Further through the project → libraries
  • Next Via import projects → modules and module dependencies
  • Next, through the import project → SDK
  • Next, through the import project → manifest.xmls
  • Android Studio launches. Make sure that there is a project in the drop-down menu of the configuration called the "app" app
  • Select the sync gradle icon (green circle)
  • A warning about the language may appear, ignoring or accepting a restart does not matter.

Below you should say "Gradle task execution", after which it will run on the device or emulator :)

enter image description here

+4
source share

This can happen for many reasons. Usually I see this when moving the directory. The easiest way I found is to close the project and then open it again using the menu item "Import project (Gradle, Eclipse, ADT, etc.). Then select the folder that will lead to reimport the project and fix any metadata / configs.

+1
source share

Short answer: File> Open> build.gradle file that you cloned with 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 might have added unnecessary additional steps, i.e. Download as ZIP, Close current project etc.

Simply put, you are VCS> Git Clone, and then open the build.gradle file. Here it is

0
source share

What worked for me

On Android Studio

Open the settings.gradle file

turn on your project

includes ': myproject'

0
source share

You must choose which example project to run. from a selection in the GitHub repository as shown here

0
source share

Well, as Android Studio correctly says, https://github.com/googlesamples/android-play-location is not a Gradle project.

However, any subdirectory of this repository. These are different projects.

So, we clone this repository and import one of its subdirectories into Gradle.

-one
source share

All Articles