神坑react native之A problem occurred configuring project ':app'报错的解决方法


windows平台下,react native本地项目连接模拟器调试,在执行 react-native run-android 命令后报错:

* 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.

解决方案:

在react native项目中的 Android 文件夹下创建一个名为 local.properties 的文件(创建一个普通的txt文本文件,然后重命名为local.properties就行),用记事本打开,写入以下内容:

sdk.dir=你本地Android SDK文件夹路径,注意,路径中的所有单斜线\应该写成双斜线\\

比如:sdk.dir=D:\\AndroidSDKLocation

保存后再次执行 react-native run-android 即可。

 

 

评论
发表评论 说点什么