首页 > 解决方案 > react-native 找不到 android sdk

问题描述

我已经在这里解决了所有类似的问题,但找不到解决方案。我正在我的 xubuntu 18.04 上测试 react-native,我被困在手机上启动应用程序的最后一步。我已经安装了 android-sdk,它位于/usr/lib/android-sdk

当我这样做时,我还看到我的设备已连接adb devices

我在 .bashrc 文件中添加了以下内容并完成$ source ~/.bashrc并重新启动了终端并尝试再次运行该应用程序

export ANDROID_HOME=/usr/lib/android-sdk
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/build-tools/24.0.0:$PATH

我不断得到:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

* 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 2s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and 
have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

我还尝试了使用 local.properties 文件并添加 sdk 的本地文件方法。我在这里做错了什么?

标签: androidreact-native

解决方案


请检查安装的sdk版本和gradle中sdk的版本

应该是一样的。

提供相同版本时,它对我有用。


推荐阅读