1.ที่หน้าจอ node.js cmd ใช้คำสั่ง
react-native --version
2.https://facebook.github.io/react-native/docs/getting-started
The SDK Manager can also be found within the Android Studio "Preferences" dialog, under Appearance & Behavior → System Settings → Android SDK.
Select the "SDK Platforms" tab from within the SDK Manager, then check the box next to "Show Package Details" in the bottom right corner. Look for and expand the
Android 8.1 (Oreo)
entry, then make sure the following items are checked:Android SDK Platform 27
Intel x86 Atom_64 System Image
orGoogle APIs Intel x86 Atom System Image
Next, select the "SDK Tools" tab and check the box next to "Show Package Details" here as well. Look for and expand the "Android SDK Build-Tools" entry, then make sure that
27.0.3
is selected.
Finally, click "Apply" to download and install the Android SDK and related build tools
เพิ่ม ANDROID_HOME=โฟลเดอร์ Android SDK
Create React Native Project
ที่หน้าจอ node.js cmd ใช้คำสั่ง
react-native init TestProject
Build React Native on Windows
1.เปิดไฟล์ project\android\app\build.gradle
แก้ไขจาก
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
cd android
จากนั้นใช้คำสั่ง
gradlew assembleRelease
3.มันจะ build จนสำเร็จ
BUILD SUCCESSFUL in 13s
ไฟล์ apk จะอยู่ที่
project\android\app\build\outputs\apk\release\