我有错误,当我开始运行android
What went wrong:
A problem occurred evaluating project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
我有错误,当我开始运行android
What went wrong:
A problem occurred evaluating project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
当前回答
只需在项目中通过android Studio打开文件夹android。 Android工作室创建必要的文件(local.properties)和下载SDK版本运行Android需要。
其他回答
转到react-native项目的android/目录 创建一个名为local的文件。这一行的属性:
sdk.dir = /Users/USERNAME/Library/Android/sdk
USERNAME是你的macOS用户名
我认为不建议更新本地。属性文件获取,以添加缺失的环境变量。
更新环境变量:
如何从iTerm2打开OSX上的AVD管理器?
Android-28 / android-30
sdk可以安装在/Library/Android/sdk或/usr/local/以确保检查它
which sdkmanager
出口ANDROID_HOME
export ANDROID_HOME=$HOME/Library/Android/sdk
or
export ANDROID_HOME="/usr/local/share/android-sdk"
然后将其添加到$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/build-tools/28.0.1:$PATH
android-23
export ANT_HOME=/usr/local/opt/ant
export MAVEN_HOME=/usr/local/opt/maven
export GRADLE_HOME=/usr/local/opt/gradle
export ANDROID_HOME=/usr/local/share/android-sdk
export ANDROID_SDK_ROOT=/usr/local/share/android-sdk
export ANDROID_NDK_HOME=/usr/local/share/android-ndk
export INTEL_HAXM_HOME=/usr/local/Caskroom/intel-haxm
我使用酿造桶安装Android SDK按照这些说明。
更多信息见https://developer.android.com/studio/intro/update#sdk-manager
我能找到的最佳解决方案如下:
Download Android Studio and SDK of your choice (Even if you think you don't need it trust me that you would need it to release the apk file and some manual changes to the android code). File > New > Import , point to the location where your react native android project is. If it ask you to download any specific SDK then please download the same. It can ask you to update gradle etc... Please keep on updating where required. If you have an existing Android SDK and you know the version then all you have to do is match that version under build.gradle of your android project.
这是gradle文件看起来的样子:
如果你的机器设置一切顺利,你可以使用Android Studio编译项目,那么没有什么会阻止你通过react-native cli build Android命令构建你的应用程序。
使用这种方法,您不仅可以解决SDK的问题,还可以解决与Android开发的机器设置相关的许多问题。导入将自动找到SDK位置并创建local.properties。因此,您不需要担心人工干预。
Windows用户
一个简单的解决方案是将SDK路径设置为environment Variables列表。
转到环境变量。(您的PC >属性) 创建新的系统变量 将变量名称设置为ANDROID_HOME 将变量值设置为Android Sdk Location 按确定(3个对话框3次)
注意:
你的Android Sdk通常位于
C:\Users\YourUserName\AppData\Local\Android\Sdk
请确保关闭当前终端,因为终端保存了所有预先存在的环境变量。
你必须写正确的全路径。 不要使用` ~/Library/Android/sdk `
vi ~/.bashrc
export ANDROID_HOME=/Users/{UserName}/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
source ~/.bashrc