You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:React Native开发出现"未能找到哈希字符串为android-23的目标"错误

Fixing "Failed to find target with hash string 'android-23'" for Iranian React Native Devs

Hey there fellow Iranian dev! I totally get how frustrating this error is—especially when you’re just starting out with React Native, and most Stack Overflow answers don’t account for the network barriers we deal with here. Let’s break down the fix tailored to our situation.

First: Understand the Problem

This error pops up because your React Native project is configured to target Android 6.0 (Marshmallow, codename android-23), but your Android Studio environment doesn’t have this SDK version installed. The usual online download method via Google’s servers often doesn’t work for us, so we need offline or alternative workarounds.

Quick Fix: Switch to a Different SDK Version (If Possible)

If your project doesn’t strictly require android-23 (most modern apps don’t), this is the easiest way out:

  • Open your project’s android/app/build.gradle file
  • Look for these lines:
    compileSdkVersion 23
    targetSdkVersion 23
    
  • Change the numbers to an SDK version you already have installed (check Android Studio’s SDK Manager for available versions—30 or 33 are safe, widely supported choices)
  • Sync your project with Gradle (click the "Sync Now" prompt that appears)

If You Must Use Android-23 (Offline Solution)

If your project or dependencies require android-23, here’s how to install it without relying on Google’s servers:

  1. Get the Android-23 SDK Package Offline
    • Ask a fellow developer to share the android-23 folder from their SDK’s platforms directory, or download a trusted offline copy of the SDK Platform 6.0 (Marshmallow)
  2. Place the Folder in Your SDK Directory
    • Locate your Android SDK path:
      • Mac: ~/Library/Android/sdk/platforms
      • Windows: C:\Users\<YourUsername>\AppData\Local\Android\Sdk\platforms
      • Linux: /home/<YourUsername>/Android/Sdk/platforms
    • Paste the android-23 folder directly into this directory
  3. Let Android Studio Recognize It
    • Open Android Studio, go to File > Settings > Appearance & Behavior > System Settings > Android SDK
    • Navigate to the SDK Platforms tab, click the "Refresh" icon in the top-right corner
    • You should see "Android 6.0 (Marshmallow)" show up—check the box next to it, then click "Apply" to confirm
  4. Install Corresponding Build Tools
    • You’ll also need Build Tools version 23.0.3 (the matching version for android-23)
    • Repeat the offline process: get the 23.0.3 folder, paste it into your SDK’s build-tools directory
    • Go to the SDK Tools tab in Android Studio’s SDK Manager, check the box for "Android SDK Build-Tools 23.0.3", then click "Apply"

Final Checks

  • Double-check that your local.properties file (in the android folder of your project) has the correct sdk.dir path pointing to your SDK installation directory
  • Clean and rebuild your project to ensure changes take effect:
    • Mac/Linux: Run cd android && ./gradlew clean in your terminal
    • Windows: Run cd android && gradlew clean in Command Prompt or PowerShell
  • Try running your React Native app again

内容的提问来源于stack exchange,提问作者mohammadavood

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:31:06