Publish cho Android
Bước 1: Tạo một keystore
Nếu đã có keystore thì bỏ qua bước này và thực hiện bước tiếp theo. Nếu không thì thực hiện đoạn lệnh bên dưới với <path> là đường dẫn tạo file key:
keytool -genkey -v -keystore key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key -storetype JKSBước 2: Tham chiếu keystore vào trong ứng dụng
Tạo file có tên key.properties trong thư mục android trong đó password, keyAlias là những thông tin khi tạo key.
storePassword=<password>
keyPassword=<password>
keyAlias=key
storeFile=<path>/key.jksBước 3: Cấu hình gradle
Thay đổi file <dir>/android/app/build.gradle tại các vị trí:
Thay đoạn android { bởi thông tin keystore
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {Thay đoạn
Bởi đoạn
Bước 4: Tạo file release
Chạy lệnh bên dưới để release apk tại thư mục build\app\outputs\apk\release
Hoặc chạy lệnh bên dưới để release file dưới dạng appbundle tại thư mục build\app\outputs\bundle\release
Một số trường hợp cần lấy SHA1/SHA256 Key cho 2 chế độ debug và relase. Thì có thể chạy lệnh như bên dưới:
Debug key
Release Key
Bước 5: Publish lên CH Play
Truy cập vào Google Console để tạo một Ứng dụng mới hoặc update ứng dụng cũ bằng file dạng appbundle (*.aab) hoặc file apk (*.apk) .
Last updated