无法在Android设备上构建react-native应用程序:找不到带有哈希字符串"android-23"的目标
这是完整的错误:failed to find target with hash string 'android-23' in: /Users/username/Library/Android/sdk
Here is the full error: failed to find target with hash string 'android-23' in: /Users/username/Library/Android/sdk
这是我的android/app
中的build.gradle
文件:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.mobile"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
我运行了Android SDK Manager,并且安装了Android SDK Build-Tools
Rev 23.0.1,以及所有适用于Android 6.0(API 23)的文件.
I ran the Android SDK Manager, and I have the Android SDK Build-Tools
Rev 23.0.1 installed, along with all the files for Android 6.0 (API 23).
我在网上搜索了此问题,并尝试了许多解决方案;重新启动终端,删除根目录中的gradle文件,确保ANDROID_HOME指向正确的目录(当我关注ReactNative文档时,我在~./bashrc
和~./bash_profile
中都复制了以下行:
# If you installed the SDK via Homebrew, otherwise ~/Library/Android/sdk
export ANDROID_HOME=/usr/local/opt/android-sdk
.
I searched online for this problem and have tried many solutions; restarting the terminal, deleting the gradle file in the root directory, making sure ANDROID_HOME points to the correct directory (As I am following the ReactNative docs, I have copied in both ~./bashrc
and ~./bash_profile
the following line:
# If you installed the SDK via Homebrew, otherwise ~/Library/Android/sdk
export ANDROID_HOME=/usr/local/opt/android-sdk
.
到目前为止,对我来说什么都没有用,而且我不断遇到同样的错误. 我应该补充说,在安装Android Studio之前一切正常,然后开始出现此错误.从那以后,我天真地卸载了Android Studio,以为它可以解决问题.
Nothing has worked for me so far and I keep getting the same error. I should add that everything was working fine until I installed Android Studio, after which point I started getting this error. I have since then uninstalled Android Studio naively thinking it would solve the problem.
请帮助我,你是我唯一的希望.
Please help me SO, you're my only hope.
-
查找android sdk位置.
(e.g /Users/username/Library/Android/sdk or /usr/local/opt/android-sdk or /Applications/ADT/sdk)
打开外壳配置文件,具体取决于您使用的外壳.
~/.bash_profile or ~/.bashrc or ~/.zshrc
.Open shell config file that it depends on what shell you're using.
~/.bash_profile or ~/.bashrc or ~/.zshrc
.编辑以下行或将以下行添加到shell配置文件中:
Edit or add the following lines to shell config file:
$ export ANDROID_HOME=`YOUR_ANDROID_SDK_PATH` $ export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools