반응형
Build APK
설명
- 구글스토어에 올리기 위해 APK 빌드하는 과정 설명
- 과정중에 jks 확장자의 key store 파일을 생성하게 되는데 이 파일은 잊어버리지 않게 잘 관리해야한다.
- 그렇지 않을 경우 스토어에 APK 업데이트를 하지 못해 새 앱으로 등록해야 하는 경우가 발생할 수 있다.
기본 생성 방법
- Build -> Generate Signed Bundle or APK
- APK 선택 후 Next
- step1
- Key store path
- Key store가 있는 경우 Choose existing을 통해 선택
- Key store가 없는 경우 Create new를 통해 생성
- 필수값
- Key store path
- Password
- Key -> Alias
- Key -> Password
- Key -> First and Last Name
- Key store password
- Key store 생성시 입력한 Password 입력
- Key alias
- Key store 생성시 입력한 Key -> Alias 입력
- Key password
- Key store 생성시 입력한 Key -> Password 입력
- Next
- Key store path
- step2
- Build Variants
- release 선택
- Signature Versions
- V1 : 체크
- V2 : 체크
- Finish
- Build Variants
- ~/app/release/app-release.apk 생성 확인
siningConfigs를 활용한 방법
key store 파일- ~/app/ 하위 경로에 .jks 파일 저장 (ex. ~/app/example.jks)
- 경로 : ~/app/keystore.properties
key.store.file=example.jks
key.store.password=123456
key.alias.name=example
key.alias.password=123456
build.gradle
android {
...
signingConfigs {
release {
def properties = new Properties()
properties.load(new FileInputStream(file("keystore.properties")))
storeFile file(properties["key.store.file"])
storePassword properties["key.store.password"]
keyAlias properties["key.alias.name"]
keyPassword properties["key.alias.password"]
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release // 추가해주어야 signed apk를 생성함
}
}
}
Build Variant 선택
- Build -> Select Build Variant
- Active Build Variant : release
- Build -> Clean Project
- Build -> Build Bundle(s) / APK(s) -> Build APK(s)
- ~/app/build/outputs/apk/release 디렉토리에 apk 파일 생성된 것 확인
- signingConfig 설정이 누락된 경우 apk 파일명에 unsigned가 붙어 생성되므로 unsigned가 붙어있는지 확인
참고
반응형
'Development > Android' 카테고리의 다른 글
[Android] Kotpref (0) | 2021.02.09 |
---|---|
[Android] SharedPreferences (0) | 2021.02.09 |
[Android] Retrofit (0) | 2021.02.09 |
[Android] Lottie (0) | 2021.02.09 |
[Android] Http Network (0) | 2021.02.09 |