错误:运行 React Native 项目时无法确定任务 ':app:compileDebugJavaWithJavac' 的依赖关系

Gab*_*oki 1 android build.gradle react-native

我在尝试运行 React Native 项目时遇到错误。

react-native run-android
Run Code Online (Sandbox Code Playgroud)

错误看起来像

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> 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 'E:\IT tasks\android\ninja-react-native\android\local.properties'.
Run Code Online (Sandbox Code Playgroud)

请帮我。

小智 5

在 local.properties 文件中添加SDK (sdk.dir) 位置路径:

对于 Windows 用户:

sdk.dir = C:\\Users"MyUserName"\\AppData\\Local\\Android\\Sdk
Run Code Online (Sandbox Code Playgroud)

对于 Mac 用户:

sdk.dir = /Users/USERNAME/Library/Android/sdk
Run Code Online (Sandbox Code Playgroud)

对于 Linux 用户:

sdk.dir = /home/USERNAME/Android/Sdk
Run Code Online (Sandbox Code Playgroud)

将用户名替换为您的用户名。并检查sdk forlder名称是Sdk或sdk,替换为它。