Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- Github
- 깃헙
- ADB
- 안드로이드 스튜디오
- viewpager
- RecyclerView
- 안드로이드
- 의존성주입
- 에러
- 유튜브
- studio
- flow
- Kotlin
- Android
- WebView
- Retrofit
- dart
- error
- 코루틴
- coroutine
- MVVM
- 스튜디오
- build
- 코틀린
- 안스
- Gradle
- image
- 레트로핏
- 안드로이드스튜디오
- 웹뷰
Archives
- Today
- Total
코딩하는 일용직 노동자
APK파일 자동 네이밍 방법. 본문
안드로이드 debug/release 앱을 빌드하면 생성되는 apk 파일에는 별다른 이름이 없습니다.

앱을 빌드할때 자동으로 버전과 날짜를 파일명에 추가해주는 방법을 사용해보겠습니다.

app레벨의 build.gradle 파일에 아래의 소스를 추가해줍니다.
android {
...
defaultConfig {
applicationId 'co.kr.test.slx'
minSdkVersion minSdk
targetSdkVersion targetSdk
versionCode 102
versionName "1.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
applicationVariants.all{
variant ->
variant.outputs.each{
// on below line we are setting a name to our apk
output->
// 앱의 이름을 지정해줍니다.
def appName = "MyApp"
// 파일생성 날짜를 이용하기 위한 처리.
def formattedDate = new Date().format('yyyyMMdd')
// 버전_(버전코드)_날짜
def verName = "v${variant.versionName}(${variant.versionCode})_$formattedDate"
// on below line we are creating a new name for our apk.
def newName = output.outputFileName
// on below line we are replacing our previous name with our app name.
newName = newName.replace("app-", "${appName}-")
// on below line we are replacing -release with our formatted date.
newName = newName.replace("-release", "_release_" + verName)
newName = newName.replace("-debug", "_debug_" + verName)
// at last we are setting our apk name to it.
output.outputFileName = newName
}
}
}
단! 이 방법은 APK파일만 자동네이밍이 됩니다. aab파일의 자동네이밍은 따로 포스팅을 했습니다.
'안드로이드' 카테고리의 다른 글
안드로이드 Retrofit2 기초 사용법 (0) | 2022.07.23 |
---|---|
aab파일 자동 네이밍 방법. (0) | 2022.07.16 |
Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. (0) | 2022.07.07 |
WebView를 사용한 고용량 이미지 표시 사례. (0) | 2022.05.27 |
Pages must fill the whole ViewPager2 (use match_parent) 에러 해결사례 (0) | 2022.05.17 |