Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Windows Linux Subsystem, the Android SDK directory does not exist

I have been running react native for a while on windows 10 but decided to install the ubuntu subsystem to continue my development as I prefer linux for dev work.

After installing ubuntu and trying to build my react native app I get this error.

The SDK directory /mnt/c/Projects/AppName/android/C:\Users\UserName\AppData\Local\Android\Sdk' does not exist.

The path is strange looking as it has my current path concatenated with the actual location of my android sdk on my windows file system (but not the path linux needs as it uses /mnt/c/ instead of C:\). That looks pretty wrong.

Here's some info about my system:

echo $ANDROID_HOME 
/mnt/c/Users/UserName/AppData/Local/Android/sdk/

less android/local.properties
sdk.dir=C\:\\Users\\UserName\\AppData\\Local\\Android\\Sdk

It seems like you should be able to link to the Windows install of the android sdk, if it used my ANDROID_HOME I think it would work. But something tells me I might need to install the sdk separately on ubuntu. I'd like to avoid that for hard disk space reasons.

I'm hoping to be able to keep react native working on windows and in the ubuntu subsystem if possible as I'm not sure if there will be some issue in the future for running react native on ubuntu. It currently works great on windows 10 so... not trying to break that.

Thoughts?

like image 229
rt_ Avatar asked Jun 26 '26 11:06

rt_


2 Answers

the local.properties file should use a Linux path instead:

# sdk.dir=C\:\\Users\\UserName\\AppData\\Local\\Android\\Sdk
sdk.dir=/mnt/c/Users/UserName/AppData/Local/Android/Sdk

and when switching the OS, just added the # to the other one line.

like image 179
Martin Zeitler Avatar answered Jun 29 '26 02:06

Martin Zeitler


I edited ~/.profile to have this line:

export $ANDROID_SDK_ROOT=/mnt/c/Users/UserName/AppData/Local/Android/Sdk
like image 27
KYHSGeekCode Avatar answered Jun 29 '26 02:06

KYHSGeekCode