A. NỘI DUNG CHÍNH
I. Node, Python2, JDKII. Android Studio
III. Tạo ứng dụng mới
Tham khảo: https://facebook.github.io/react-native/docs/getting-started
B. CÀI ĐẶT
I. Node, Python2, JDK
- Cài cả 3 công cụ trên thông qua Chocolatey
+ Mở PowerShell bằng quyền Admin
+ Paste đoạn sau và Enter "Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
+ Chạy dòng lệnh sau để cài Node, Python2, JDK
choco install -y nodejs.install python2 jdk8
- Tải xuống và cài đặt Android Studio
- Cài đặt các thành phần
Android SDK
Android SDK Platform
Performance (Intel ® HAXM)
Android Virtual Device
- Cài đặt SDK
Vào SDK Manager
- Vào Android 9 (Pie)
Vào SDK Manager
- Vào Android 9 (Pie)
Android SDK Platform 28
Intel x86 Atom_64 System Image
hoặc làGoogle APIs Intel x86 Atom System Image
- Vào SDK Tools chọn 28.0.3 trong Show Package
- Cài đặt biến môi trường
Chuột phải Computer - Properties - Advanced system settings - Enviroment Variables...
Chọn New thêm biến ANDROID_HOME, đường dẫn mặc định
- Chỉnh sửa biến "Path" trong System Variables
Edit biến Path - Thêm c:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\platform-tools;
III. Tạo ứng dụng mới
- Tạo ứng dụng
- Trong cửa sổ cmd hoặc Node command prompt
- Cài đặt biến môi trường
Chuột phải Computer - Properties - Advanced system settings - Enviroment Variables...
Chọn New thêm biến ANDROID_HOME, đường dẫn mặc định
c:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk
Edit biến Path - Thêm c:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\platform-tools;
III. Tạo ứng dụng mới
- Tạo ứng dụng
- Trong cửa sổ cmd hoặc Node command prompt
npx react-native init AwesomeProject
Giao diện sau khi tạo Project mới tên là AwesomeProject
- Chạy chương trình
+ Khởi động máy ảo Genymotion hoặc gắn thiết bị điện thoại vào
+ Máy ảo nên để API 28 trùng với API trong SDK
+ Máy ảo nên để API 28 trùng với API trong SDK
cd AwesomeProject
npx react-native run-android
*Lệnh cd để di chuyển đến AwesomwProject
*Lệnh npx react-native run-android để chạy ứng dụng trên nên Android
* Lỗi "Unable to load script" sẽ được hướng dẫn trong "React-native Bài 1 Hello World"
0 nhận xét:
Đăng nhận xét
Thank you!