547

I recently tried to import sample Android games I downloaded from Google's developer website. After importing them into Android Studio, I'm getting the following error:

Error: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

What is this? I want to run the sample programs from Android Studio.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Sameer Shamsudeen
  • 5,577
  • 2
  • 11
  • 8
  • 4
    Check this link http://xinyustudio.wordpress.com/2014/07/02/gradle-sdk-location-not-found-the-problem-and-solution/ – IntelliJ Amiya Dec 23 '14 at 12:32
  • [sdk.dir is setted but still cannot work](https://stackoverflow.com/q/25596284/6521116) – LF00 Jun 07 '17 at 03:17
  • to the future visitors, please check this answer https://stackoverflow.com/a/56089502/7854303 – Manish Sep 09 '20 at 06:24
  • this was happening with me in the first ever hello world, even the env variable was set correctly, what I did is, open the android folder in android studio and hit the run button(green play icon) and it worked, make sure your metro is running while you are doing this, i think it was happening because i didnt opened the android studio after installation when I opened the android folder in andriod studio I noticed it updated few things and now even npm run android is working fine – Inzamam Malik Mar 12 '21 at 19:10
  • If freshly git-cloned, just do File -> Sync Project with Gradle Files – Pavel Jun 08 '23 at 14:25

52 Answers52

761

Please follow the below steps:

  • Go to your react-native Project then go to the android directory Create a file with the following name:

local.properties

  • Open the file and paste your Android SDK path like below:

For windows users:

sdk.dir=C:\\Users\\UserName\\AppData\\Local\\Android\\sdk

or (for newer versions of Android Studio / IntelliJ IDEA):

sdk.dir=C\:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk

Where USERNAME your PC user name. Also, make sure the folder is sdk or Sdk.

Example:

sdk.dir=C:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk

or:

sdk.dir=C\:\\Users\\USERNAME\\AppData\\Local\\Android\\Sdk

For Mac users:

sdk.dir = /Users/USERNAME/Library/Android/sdk

Where USERNAME is your OSX username.

For Linux (Ubuntu) users:

sdk.dir = /home/USERNAME/Android/Sdk

Where USERNAME is your linux username (Linux paths are case-sensitive: make sure the case of S in Sdk matches)

In case this doesn't work, add ANDROID_HOME variable in "Environment Variables" as C:\Users\USER\AppData\Local\Android\Sdk

enter image description here

ikathegreat
  • 2,311
  • 9
  • 49
  • 80
Hoque MD Zahidul
  • 10,560
  • 2
  • 37
  • 40
  • i am working with open cv what should i do to add NDK? – Innocent Oct 02 '19 at 01:48
  • It helped. Actually this solution is hinted in the error wording itself. I use IntelliJ on Mac and in project structure I have SDK correct path. Why still do I need that in local.properties then? – Alex Martian Feb 05 '20 at 08:47
  • if you're using `eas build` (`expo build` has been deprecated), this is no longer working, and you have to define the env variable in `eas.json`, also the path to the android SDK may be different (I don't have it in my home directory) – jave.web Mar 23 '22 at 18:04
  • 1
    adding ANDROID_HOME worked for me but I had to add it to System variables. It didn't worked on User variables. – Kiril Dobrev Jan 17 '23 at 16:51
  • 1
    @Hoque MD Zahidul : Your solution worked for me and it saved my day :). Thank you – Nirmala Sudhir May 16 '23 at 04:48
280

The project might be missing a settings.gradle file. Make sure that file exists from the project you are importing. If not add the settings.gradle file with the following :

include ':app'

Save the file and put it at the top level folder in your project.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Joseph
  • 5,793
  • 4
  • 34
  • 41
  • 28
    How can I tell if my project is missing `settings.gradle`? Where is that file usually stored? Where do I type `include ':app'`? What exactly does `include ':app'` do/generate? Can you please add more detail to your answer? – Tot Zam Nov 17 '16 at 05:50
  • 2
    @TotZam its stored in the root of your project – Joseph Nov 17 '16 at 06:01
  • 2
    Found it. Thanks. For future reference, where would I run `include ':app'`? I'm quite new to Android and trying to find my way around. – Tot Zam Nov 17 '16 at 06:04
  • 3
    You don't run `include :app`, if you are using Android Studio, that lets Android Studio add your project module so you can run it without further configuration. After you add the line in `settings.gradle` you will notice the `Play` button becomes active after gradle finishes building and downloading packages – Joseph Nov 17 '16 at 06:11
  • 1
    Put your project folder name instead of 'app' if it's different. It works. – Priyank Patel Nov 27 '16 at 06:09
  • Thanks a lot! It helped in importing [MPAndroidChart Example](https://github.com/PhilJay/MPAndroidChart/tree/master/MPChartExample) which was just stuck at this error :P – Vinay Vissh Feb 22 '17 at 07:54
  • This is often a symptom of attempting to open a project that's not standalone and relies on a parent project. So while this answer is correct, in some circumstances it won't help because most Android projects are reliant on a parent gradle project to for essential configuration. – Avi Cherry Jun 15 '17 at 20:01
  • This gives me " Plugin with id 'com.android.application' not found." – Samuel Owino Jun 22 '19 at 22:02
  • This seems to be a gradle issue, did you try this https://github.com/udacity/ud839_Miwok/issues/87 – Joseph Jun 23 '19 at 08:28
  • Thanks a lot! Had everything else set up but this was missing. A bit weird that Android Studio doesn't give a more understandable error. – Erik Sillén Oct 08 '19 at 16:32
180

You have to just copy your local.properties file to the folder where project is stored and it will work like charm. But remember, it must be placed in the root folder where the project is stored.

starball
  • 20,030
  • 7
  • 43
  • 238
Harsh Mittal
  • 2,868
  • 1
  • 16
  • 21
  • 4
    But I have to copy it everytime? This seems like a hack than the correct approach – pblead26 Jul 14 '16 at 19:41
  • Its is the most easy solution for this problem as you dont have to change anything in project. There are also other solution in which you have to do change in code , but I think for such issue one cannot afford to waste much time. – Harsh Mittal Jul 20 '16 at 18:30
  • This worked for me when I had this issue after downloading ExoPlayer 2.1. – user1147171 Dec 23 '16 at 05:54
  • if anyone facing **You have not accepted the license agreements...** error after the above step see here http://stackoverflow.com/a/41078173/1778834 – yashhy Mar 30 '17 at 18:26
  • 3
    It works, but Shouldn't Intelij generate this automatically ? tks ! – cesarsicas May 31 '17 at 14:04
  • 4
    This does not work for me. The file is present, but I still have the error – rommex Jun 12 '17 at 08:15
  • yes it was in sample folder not in project root, thanks! – user25 Jul 11 '18 at 18:36
  • 2
    just open the android folder by android studio, when android studio opens the 'android' folder, local.properties will be created automatically. – MING WU Jun 24 '19 at 01:26
  • https://xinyustudio.wordpress.com/2014/07/02/gradle-sdk-location-not-found-the-problem-and-solution/ – Md Shahnawaz Oct 14 '20 at 06:23
79

Please follow bellow points it work's for me:

  1. Go to your Project -> Android
  2. Create a file local.properties
  3. Open the file
  4. Paste your Android SDK path depending on the operating system:

    4.a Windows

    sdk.dir = C:/Users/USERNAME/AppData/Local/Android/sdk

    4.b Linux or MacOS

    sdk.dir = /home/USERNAME/Android/sdk

    Replace USERNAME with your user name

CuriousSuperhero
  • 6,531
  • 4
  • 27
  • 50
Anjali-Systematix
  • 1,531
  • 14
  • 17
54

Check out in your local.properties file

sdk.dir=C\:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk

properly write this format, and also check / slas using for path

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Qutbuddin Bohra
  • 1,165
  • 1
  • 11
  • 29
  • I edited local.properties with this sdk.dir=C:\\Users\\sameer\\Android\\adt-bundle-windows-x86-20140702\\sdk, any error in this – Sameer Shamsudeen Dec 23 '14 at 12:44
  • yeah after C put \ ... Svae with thishope done. sdk.dir=C\:\\Users\\sameer\\Android\\adt-bundle-windows-x86-20140702\\sdk – Qutbuddin Bohra Dec 23 '14 at 13:08
  • This works nice with eclipse. Just create the file local.properties within the downloaded project and paste the sdk.dir . In my case it was : "sdk.dir=C\:\\adt-bundle-windows-x86_64-20140321\\sdk" – George Papatheodorou May 29 '15 at 08:17
  • if anyone facing **You have not accepted the license agreements...** error after the above step see here http://stackoverflow.com/a/41078173/1778834 – yashhy Mar 30 '17 at 18:27
  • I have installed android on my windows 10 m/c but there is no such folder sdk.dir=C\:\\Users\\USERNAME\\AppData\\Local\\Android? – Rohan Gala May 11 '17 at 18:25
  • My android SDK is in D:\Tools\Android\ directory not in C:\ setting sdk.dir=D:\Tools\Android Doesn't work. – Mayur Baldha May 18 '17 at 06:33
  • This error is also related with OS language(!!!). If you are using a OS language other than english than try to convert your OS language to english, I am sure it will work. This is only for Windows. – macmuri Apr 05 '19 at 06:56
48

Here is a work around for the problem when you click "Run App" (green arrow) and get the following in the Edit Configuration dialog:

Error: Please select Android SDK

In Android Studio, do:

  1. From the menu, choose File > Settings.
  2. In the settings dialog, go to Appearance & Behavior > System Settings > Android SDK.
  3. Look at the top for Android SDK Location, and click the Edit button
  4. Hit Next, Next, Finish to accept the defaults

This seems to save away the SDK location - even though nothing has changed - into some internal location. I inspected the .idea and .gradle folders but didn't see what Studio did to change a config file - but now I can run the app.

And to summarize the previous fixes - these are normally OK for a repo without build problems:

  • local.properties file is copied into the root folder by Studio.

  • The path in the local.properties file has the correct path to the android SDK - in my case it is sdk.dir=C:\\android\\sdk (note that this path has a different format - Studio should write this file for you based on the Text Entry field in the Android SDK Settings dialog)

  • settings.gradle file is present in the repo - and references the application folder (typically :app)

Mjaustro
  • 727
  • 8
  • 11
Jim Andreas
  • 1,557
  • 1
  • 17
  • 29
45

This problem is encountered when you try to import an Android Studio project from the ../app/build.gradle file.

Import the project by selecting the ../build.gradle file located in the root directory of your project.

Michael Saffold
  • 561
  • 4
  • 5
43

I came across the same issue but a little bit different error message is

SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at "xxx"

MAC & ReactNative

Add local.properties

  1. Find your Android SDK location

    /Users/yourMacUserName/Library/Android/sdk
    
  2. Create local.properties under rootProject/android/local.properties.

  3. Add sdk path into it

    sdk.dir = /Users/yourMacUserName/Library/Android/sdk
    

This normally works, but if you are working in a team with other team members, then yourMacUserName is different.

OR

Set ANDROID_SDK_ROOT variable

  1. Edit your ~/.zshrc or ~/.bashrc or ...
  2. Add SDK path:

    export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
    
  3. Open a new terminal tab or source ~/.zshrc
  4. echo $ANDROID_SDK_ROOT to test the print correct SDK path.

Alternatively, you also can add your path export PATH=${PATH}:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools to use some useful commands.

William Hu
  • 15,423
  • 11
  • 100
  • 121
  • EAS builds: use `eas.json` under build => production (or other mode) make sure you have `{ "env": { "ANDROID_SDK_ROOT": "/your/path/to/androidSDK" }` – jave.web Mar 23 '22 at 18:10
36
  1. Go to your React-native Project -> Android

  2. Create a file local.properties

  3. Open the file

  4. paste your Android SDK path like below

     in Windows sdk.dir = C:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk
    
     in macOS sdk.dir = /Users/USERNAME/Library/Android/sdk
    
     in linux sdk.dir = /home/USERNAME/Android/Sdk
    
  5. Replace USERNAME with your user name

  6. Now, Run the react-native run-android in your terminal

or

Sometimes project might be missing a settings.gradle file. Make sure that file exists from the project you are importing. If not add the settings.gradle file with the following :

include ':app'

Save the file and put it at the top level folder in your project.

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
21

If you have this problem when you pull a react-native project, you just need to open the android project with Android Studio. Everything you need will be automatically created.

  • Open Android Studio
  • File -> Open
  • Choose the android folder under your react-native project folder
  • Wait for AndroidStudio to complete setup
  • You can now close Android Studio

OR

If you have installed the AndroidStudio command line launcher:

  • Run this in your react-native root folder
studio android/
  • Wait for AndroidStudio to complete setup
  • You can now close Android Studio
gianlucaparadise
  • 1,678
  • 20
  • 32
  • this answer is so underrated. I've come here twice now and it solved both the times. thanks a lot. – Manish Sep 09 '20 at 06:22
16

In Linux:

If you have already downloaded the android SDK but its not being found.

The problem might be that the file local.properties needs to be inside the same directory as gradle stuff for gradle to find it when building and running adb.

For my react-native project using gradle I needed to put the local.properties file to Myprojectname/android/ folder.

As I had unzipped the SDK to Downloads so I just use that path in the file with a row like this:

sdk.dir=/home/USER/Downloads/android-sdk-linux
MHSaffari
  • 858
  • 1
  • 16
  • 39
Mika
  • 161
  • 1
  • 4
14

I resolved this issue by creating ANDROID_HOME environment variable as follows in windows.

ANDROID_HOME=C:\Users\<user_name>\AppData\Local\Android\sdk

Restart Android Studio it should build project!

mumair
  • 2,768
  • 30
  • 39
  • I already had an ANDROID_SDK which points to the same dir, so for me it was `ANDROID_HOME=$ANDROID_SDK` – Martijn Nov 23 '18 at 09:24
10

If you are trying to run Google android sample code, try to import the entire repository instead of an individual sample.

Here is instructions.html, included with the Google Calendar API sample code.

  • Import calendar-android-sample project
  • Select "Import Project..." or File > Import Project...
  • Select [someDirectory]/google-api-java-client-samples/build.gradle and click OK.
    • Note: it will not work if you try to import [someDirectory]/google-api-java-client-samples/calendar-android-sample/build.gradle
  • Select "Use local gradle distribution" with "Gradle home" of [someDirectory]/gradle-2.2.1 and click OK.
Nate
  • 698
  • 1
  • 7
  • 18
  • If anyone is trying to run one of the samples in the facebook-android-sdk, this tip helped me run it. Loading only one of the examples doesn't work. – Boommeister Dec 14 '20 at 07:39
8

Just Remove .idea folder and import the project again. It's worked for me.

Akshay Sharma
  • 157
  • 2
  • 6
8

enter image description here

Go to the android folder and create local.properties files and paste your SDK path

Sourabh Gera
  • 862
  • 7
  • 7
7

There is not a single reason for this error.

  1. settings.gradle may be missing or the content in it may be wrong.
  2. local.properties may be missing or the sdk path may be wrongly written.
piet.t
  • 11,718
  • 21
  • 43
  • 52
Arhat Baid
  • 1,011
  • 10
  • 18
6

In my case I was using linux and putting double quote around the path inside local.properties like

sdk.dir = "/root/Android/Sdk/"
export ANDROID_SDK_ROOT = "/root/Android/Sdk/"

So it should be

sdk.dir = /root/Android/Sdk/
export ANDROID_SDK_ROOT = /root/Android/Sdk/

and .bash_profile

enter image description here

TAHA SULTAN TEMURI
  • 4,031
  • 2
  • 40
  • 66
6

I had this error in flutter so i fixed it by going to android->app->build.gradle

and changing targetSdkVersion from 28 to 29 and compileSdkVersion to 29 from 28 and it worked for me

Zeeshan Mehdi
  • 1,241
  • 1
  • 17
  • 18
5

create a local.properties file in your root directory of your project with the following content

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Oct 24 17:40:53 CEST 2017

sdk.dir=/Users/****/Library/Android/sdk
Ilker Baltaci
  • 11,644
  • 6
  • 63
  • 79
4

put these two lines in your .bashrc file and run source ~/.bashrc

export ANDROID_HOME=/Users/$USER/Library/Android/sdk export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

For linux I did this.(For the first line)

export ANDROID_HOME=/home/$USER/Android/Sdk
Stanley
  • 499
  • 1
  • 7
  • 15
Tzvetlin Velev
  • 1,897
  • 2
  • 17
  • 31
4

In my case, I had to close Project and open again. It worked fine. Like This

Close Project

enter image description here

And again Open Project Again

enter image description here

Muhaiminur Rahman
  • 3,066
  • 20
  • 27
  • After adding sdk.dir path and also to ~/.bashrc, nothing worked. But then I closed and opened again and it worked. Thanks! – grc Apr 05 '20 at 21:39
4

Follow followings steps :

  1. Create a file under 'android' folder with name 'local.properties'

  2. Add this line in file 'local.properties' as

    sdk.dir=/Users/bijendrasingh/Library/Android/sdk

Add here your android sdk path.

Bijendra Singh
  • 617
  • 6
  • 4
4

There can be two different possibilities :

1). Either you SDK location is incorrect in local.properites file.

2). Or the file is missing, this can happen if you have cloned a project, so just create a local.properites file under Gradle Scripts foler, and then set up the sdk path.

Set up the correct sdk path like this :

sdk.dir=YOUR_PATH_TO_THE_SDK

For mac users the path should be:

/Users/USER_NAME/Library/Android/sdk

For windows users the path should be:

c:\Users\USER_NAME\AppData\Local\Android\Sdk 
Anubhav
  • 1,984
  • 22
  • 17
3

For Mac/Linux users

You need to add ANDROID_HOME to your path, add the following to your .bashrc || .zshrc || .profile file

# change $HOME to the path where you installed android Sdk
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools

Then run

$ source ~/.bashrc || .zshrc || .profile

Environment variables in bash_profile or bashrc?

Difference between .bashrc and .bash_profile

Junius L
  • 15,881
  • 6
  • 52
  • 96
3

This solution actually works for me.. go to this pc -> properties -> advanced system settings -> environment variables -> then in system variable create new variable with name ANDROID_SDK_ROOT and value C:\Users{USERNAME(Replace it with your username}\AppData\Local\Android\Sdk

and make sure that if real android mobile using usb debugging is enabled. (very important)

then close cmd and restart it should work.

3

I had a situation where I already had the local.properties file set up but I was still getting this error. Turns out, if your project has a submodule, you have to copy the local.properties into the submodule folder as well.

Sharp
  • 1,335
  • 1
  • 12
  • 27
3

here is my solution it worked for it might help someone else, go to your file -> repair ide. enter image description here

prompt will appear below asking to re scan project indexes, it will look through your files and fix missing files, after it finishes it will ask your to invalidate caches and restart, make sure to tick the two optionals:

enter image description here

Mado
  • 329
  • 3
  • 16
2

the best and the easiest way is to create new Android project move "app" folder from non working project to that newly made one and add the needed dependencies in the gradle of your new project and everything will work perfectly )

Armen Hovhannisian
  • 932
  • 1
  • 11
  • 27
  • This corrected the issue on both the mac High Serria and Windows 10. Great answer and efficient. – Val Mar 22 '18 at 03:09
2

I got this error after freshly cloning a repository. I expected local.properties to be generated automatically, but it wasn't. I was able to generate it by re-importing the Gradle project.

File > Re-import Gradle Project
M. Palsich
  • 1,748
  • 13
  • 18
  • This helped. After "Re-import Gradle Project" was launched, the following 2 errors were printed to console which helped me to detect the problem: **Invalid Gradle JDK configuration found**, **Project JDK is not specified**. So everything started to work after I fixed the JDK path in Settings. – Michal Vician Apr 05 '19 at 09:37
  • After JDK path was fixed I also had to restart the IDE with "File > Invalidate Caches / Restart ..." option. – Michal Vician Apr 15 '19 at 12:33
2

If all else fails, copy the local.properties file to the root of the project directory. Simply.

tim4dev
  • 2,846
  • 2
  • 24
  • 30
2

Anyone using Jenkins, might get it useful

You need to define a global variable name ANDROID_HOME with the value of the path to android sdk.

For mac, it is /Users/YOUR_USER_NAME/Library/Android/sdk

touhid udoy
  • 4,005
  • 2
  • 18
  • 31
1

Check, 1. In Module settings, whether, SDK location is proper. 2. If Yes, check for local.properties file (Not the one placed inside app module, but the one placed outside the app module, at parent level). If not present add it with below lines inside it.

sdk.dir=/path/to/sdk/../Android/Sdk
Max Droid
  • 924
  • 9
  • 10
1

Found working solution for me. Without adding local.properties and set up ANDROID_HOME variable. Seems like a bug in Android Studio and Intellij IDEA. You just need to ask IDE to "reset" path to Android SDK. 'SDK Location not found' in Android Studio despite having the environment variable set correctly

1

I find My Solution too. I just Sync Gradle I have all folders (settings .gradle,..) but I take this error .. I just Run Sync Project With Gradle File and EditSdkLocation And be ok ...

1

i was thinking your setting.gradle file is missing. Copy this file another project and paste your project.It will work i think.

in setting.gradle file ,

include ':app'

thats all. Have a good day.

ozanurkan
  • 399
  • 4
  • 13
1

For me the problem was that I haven't created any virtual devices after fresh installation of android studio. So, expo kept complaining vaguely about the sdk location while the main issue was the missing virtual devices. Hope this helps somebody in the future, had me searching for a couple of hours.

PS: here you can find out how to create one https://developer.android.com/studio/run/managing-avds

Omar Dulaimi
  • 846
  • 10
  • 30
1
  1. cd ./android, create file file local.properties

  2. paste this code sdk.dir=C\:\\Users\\muhammad ali\\AppData\\Local\\Android\\Sdk

  3. change location to as per your sdk is located. you already have local.properties file, good

  4. find similar file of code sdk.dir=C\:\\Users\\muhammad ali\\AppData\\Local\\Android\\Sdk

  5. change location to as per your sdk is located

  6. run npx react-native run-android

ramzesenok
  • 5,469
  • 4
  • 30
  • 41
1

The issue I had is that local.properties was committed into git repository even though it says explicitly not to do it ## This file must *NOT* be checked into Version Control Systems,.

To fix the issue locally on MacOS I just went to File > Project Structure... in Android Studio and it fixed it automatically.

To fix the issue in the git I executed the following commands in the project root directory:

echo -e "\nlocal.properties" >> .gitignore
git add .gitignore
git rm local.properties --cached
git commit -m "Removed local.properties from the git"
Anton Plebanovich
  • 1,296
  • 17
  • 17
1
  • first scenario :-

look for local.properties file in your project and set sdk path.

  • second scenario :-

if you you don't have one then copy from other project and set it according your sdk path .

Nikit Dungrani
  • 185
  • 1
  • 7
1

Sync Project with Gradle Files

user_MGU
  • 978
  • 11
  • 11
0

I just faced the issue when I cloned my repo from Github and ran ./gradlew clean assembleDebug. I confirm I have ANDROID_HOME in my .bashrc file.

So, I imported the project into Android Studio. Noticed that extension of my settings.gradle file is .kts, settings.gradle.kts. When I am done with import then I ran ./gradlew clean assembleDebug and didn't get any issue.

Hesam
  • 52,260
  • 74
  • 224
  • 365
0

I tried

sdk.dir = \Users\OLUWAGBEMIGA\AppData\Local\Android\sdk 

and it worked, I simply pasted it in the project folder and outside.

In the environment variable I also used the sdk link above and the name ANDROID_HOME as the path name. Close everything reopen and Cabom it all worked

Syscall
  • 19,327
  • 10
  • 37
  • 52
0

In my case i had the error sdk location not found

What i did: I went to the cloned project from git opened the project directory opened the app directory inside the project copied the local.properties file and then pasted it in the project directory Then it worked

Dinga
  • 21
  • 2
0

For me, this problem is caused by opening the cloned project with "open an existing project" instead of "import".

The file "setting.gradle" already exists in the downloaded project. However, it doesn't get picked up by Android Studio using "open an existing project" option, only "import" will impose Android Studio to interpret the whole project settings.

The same idea has been mentioned implicitly in M.Palsich's answer.

StndFish
  • 99
  • 5
0

As I checked that some are still getting error when they create local.properties file in Android directory and writes the path. The reason you're getting error is because there's spelling mistake in writing path.

0
  1. Go to your local properties file

  2. Check the Sdk location (It might have been changed if you have imported file with a another user's Sdk location, find yours and get it right, that's it).

0

Open Android Studio, go to the File menu and select File Structure and specify an SDK with compileSdkVersion or targetSdkVersion that you defined in the "app/build.gradle" file.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
0

If you are using Flutter you clearly try to change the name from Androidmainfest.xml just don't change it back to the old name some packages would help you with that in pub.dev

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 29 '21 at 22:56
0

I solved that issue with File/Invalide cache/Restart, then click on Set SDK.... when prompted by the error.

Lucas
  • 458
  • 4
  • 6
0

The part in the setting.gradle file was as follows.

rootProject.name = "SampleProject" include ':app'

'local.properties' file was created by changing the above piece of code as below and the problem was solved.

include ':app' rootProject.name = "SampleProject"

In short, moving the include ':app' part to the top solved the problem.

-1

To know the exact sdk files in your directory, got to android studio, select tools>sdk

just copy and make sure it got double // in your path.

Hope it can help

-1

I also tried the above all solutions but it's not working . Then i checked the ANDROID_HOME variable. There i put one extra space after the variable name.Then i removed that space, and checked .it's working.So please make sure there should not be any extra space before and after the ANDROID_HOME variable