解决React-Native: SDK location not found

使用react-native run-android时报错

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.

BUILD FAILED

Total time: 2.723 secs
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:

原因分析
我是在现有Android项目中集成的ReactNative,由于ReactNative生成的android目录下面缺少了local.properties这个文件,而这个文件给项目配置了Android SDK的路径,没有这个文件也就找不到SDK,所以就报错了。
解决办法
直接把项目根目录下面的local.properties文件复制到项目根目录/android 这个目录下面,重新编译就可以了。

猜你喜欢

转载自blog.csdn.net/huanglin_developer/article/details/80237291