안드로이드 스튜디오에서 build – Generate Signed APK 를 하면 apk-release.apk 라는 이름으로 파일이 만들어진다.
이 이름 바꾸기 은근 귀찮다.
출처 : http://stackoverflow.com/a/28992851/1025379
defaultConfig { minSdkVersion 22 targetSdkVersion 22 versionCode 1 versionName "1.0" archivesBaseName = "MyApp_v" + versionName + "_" + new Date().format("yyyyMMdd_HHmmss") }
이렇게 하면
MyApp_v1.0_20150618_170557-release.apk
이런 이름으로 생성된다.
이 방법을 사용하면 debug.apk 파일이름 역시 바뀌게 돼서 나중에 되면 폴더에 계속 쌓이게 될 것 같다.
그래서
출처 : http://stackoverflow.com/a/24650026/1025379
buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' applicationVariants.all { variant -> variant.outputs.each { output -> def formattedDate = new Date().format('yyyyMMdd_HHmmss') def apkName = "MyApp_v" + variant.versionName + "_" + formattedDate + ".apk" output.outputFile = new File(output.outputFile.parent, apkName) } } } }
이렇게 하면
MyApp_v1.0_20150618_170837.apk
이런 이름으로 나온다.
근데 release에만 해놨는데도 debug 모드에서도 저 이름으로 apk 가 생성된다…
그냥 안쓰는게 나을 것 같다.
Android Studio 3.0은 또 바뀌었다. 이렇게 하면 디버그 모드일 때는 apk 하나만 생성되고, 릴리즈 모드에서는 날짜가 붙어서 만들어진다.
android { buildTypes { release { applicationVariants.all { variant -> variant.outputs.all { outputFileName = "MyApp_${new Date().format('yyyyMMdd_HHmm')}.apk" } } } debug { applicationVariants.all { variant -> variant.outputs.all { outputFileName = "MyApp_debug.apk" } } } } }