หน้าหลัก » React Native » React Native วิธีแก้ไข Android SDK – Required for building and installing your app on Android

React Native วิธีแก้ไข Android SDK – Required for building and installing your app on Android




Android
 ✖ Adb - No devices and/or emulators connected. Please create emulator with Android Studio or connect Android device.
 ✓ JDK - Required to compile Java code
 ✓ Android Studio - Required for building and installing your app on Android
 ✖ Android SDK - Required for building and installing your app on Android
   - Versions found: 29.0.2, 30.0.2, 31.0.0, 34.0.0
   - Version supported: 33.0.0
 ✓ ANDROID_HOME - Environment variable that points to your Android SDK installation

เมื่อเราตรวจสอบความพร้อมของเครื่องมือในการพัฒนา React Native ด้วยคำสั่ง npx react-native doctor จากนั้นจะพบว่ามี error ตรง Android SDK ดังรูป

React Native วิธีแก้ไข Android SDK - Required for building and installing your app on Android

ปัญหาเกิดจากยังไม่ได้ติดตั้ง Android SDK Build Tools เวอร์ชั่น 33.0.0 ตามที่ไฟล์ android/build.gradle กำหนด

React Native วิธีแก้ไข Android SDK - Required for building and installing your app on Android

วิธีแก้ไข

1.ให้เข้าไปที่ SDK Manager

React Native วิธีแก้ไข Android SDK - Required for building and installing your app on Android

2.ไปที่แถบ SDK Tools > เลือก Show Package Details > เลือก 33.0.0 > OK

React Native วิธีแก้ไข Android SDK - Required for building and installing your app on Android

3. รอ Android SDK Build-tools 33.0.0 ติดตั้งเสร็จ แล้วกดปุ่ม Finish ออกจากหน้าจอได้เลย

4. พิมพ์ npx react-native doctor เพื่อตรวจสอบอีกครั้ง จะพบว่า Android SDK พร้อมใช้งานแล้ว

React Native วิธีแก้ไข Android SDK - Required for building and installing your app on Android