React Native: Could not determine the dependencies of task ‘:app:installDebug’

I`ve been trying to run the default React Native App in my Android Emulator from Android Studio.

Yesterday I got the message that the Android sdk cant be found so i created the local.properties file in my android folder with (sdk.dir = C:Users”MyUserName”AppDataLocalAndroidSdk).

That worked but now i get another problem:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> java.io.IOException: Die Syntax fuer den Dateinamen, Verzeichnisnamen oder die 
Datentraegerbezeichnung ist falsch

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get 
more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 11s

error Failed to install the app. Make sure you have the Android development environment set up: 
https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

I tried cd android -> gradlew clean but got the same Problem.

I also tried npm install --save-dev jetifier-> npx jetify -> npx react-native run-android but got the same Problem.

I googled for about 4 hours but cant find anything the solves my problem.

Im pretty new to react and react native but thanks in advance for your help.

Answer

Use \ instead of in your pathvariable in local.properties

So “sdk.dir = C:Users”MyUserName”AppDataLocalAndroidSdk” becomes “sdk.dir = C:\Users”MyUserName”\AppData\Local\Android\Sdk”