Frosty619 Frosty619 - 13 days ago 7
Android Question

Unable to build react-native app on Android device :failed to find target with hash string 'android-23'

Here is the full error:

failed to find target with hash string 'android-23' in: /Users/username/Library/Android/sdk


This is the
build.gradle
file in my
android/app
:

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"
}
}


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

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
.

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.

Answer
  • Find your Android SDK installed location.(e.g /Users/username/Library/Android/sdk or /usr/local/opt/android-sdk or /Applications/ADT/sdk)

  • Open your ~/.bash_profile and edit like.

    sudo gedit ~/.bash_profile

    • export ANDROID_HOME = YOUR_ANDROID_SDK_PATH

    • export PATH = $PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools`

  • Restart the terminal run again.

References

Comments