所以我收到了这个错误
~/projects/personal-projects/react/myapp ⌚ 18:12:24
$ react-native run-android --variant=release
Scanning folders for symlinks in /Users/user/projects/personal-projects/react/myapp/node_modules (22ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installRelease)...
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: 14.706 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:
https://facebook.github.io/react-native/docs/getting-started.html
我已经安装了我的android sdk,我也安装了java。
这就是我.bach_profile
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export JAVA_HOME=$Home/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
我尝试添加local.properties文件,并添加指向我的Android / sdk文件夹的sdk.dir。但这个错误仍然存在。我该如何解决这个问题?
答案 0 :(得分:1)
您需要在环境变量中添加ANDROID_HOME,JAVA_HOME变量 系统路径中运行android apk的工具和平台工具。
在环境变量中设置ANDROID_HOME变量。
在环境变量中设置JAVA_HOME变量。
答案 1 :(得分:0)
请在文件夹local.properties
中创建文件android
,然后在文件
sdk.dir=/Users/apple/Library/Android/sdk(Please add your sdk path here)
答案 2 :(得分:0)
所以问题的解决方案是:
1)在我的.bash_profile中添加我的ANDROID_HOME和JAVA_HOME路径
2)创建local.properties
并在android文件夹中添加sdk.dir=<PATH TO ANDROID SDK>
。