etain avatar

Android Signing Key Password 감추기

etainclub

Published: 10 Nov 2019 › Updated: 10 Nov 2019Android Signing Key Password 감추기

Android Signing Key Password 감추기

이전글에서 Google Map API key를 감추는 방법을 알아봤습니다.
Google Map API Key 감추기

그런데 안드로이드 앱에서 감춰야 할 게 또 있습니다. 바로 signing key 암호입니다.

안드로이드 앱 릴리스 빌드

안드로이드 앱에서 릴리스를 위한 signing key를 생성하는 부분은 아래에 매우 상세히 나타나 있습니다.
https://dev-yakuza.github.io/ko/react-native/android-running-on-device/

signing key 파일 생성
$ keytool -genkey -v -keystore etainclub-release-key.keystore -alias etainclub-key-alias -keyalg RSA -keysize 2048 -validity 10000

그러면 android/app 밑에 etainclub-release-key.keystore 파일이 생성됩니다. 키 파일 이름은 적절히 변경하시면 됩니다.

그런데 여기서는 signing 암호를 gradle.properties에 저장하고 있습니다. 이 파일은 local.properties와 달리 앱 설정에 필요한 내용을 저장해야 합니다. 즉, 비공개가 아니라 공개되어야 하는 파일입니다.

그래서, signing 암호도 local.properties에 넣고 사용하면 좋습니다.
local.properties 파일에 아래와 같이 signing 암호와 관련된 내용을 추가합니다.

// local.properties
MYAPP_RELEASE_STORE_FILE=etainclub-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=etainclub-key-alias
MYAPP_RELEASE_STORE_PASSWORD=xxxxxxxxxxx
MYAPP_RELEASE_KEY_PASSWORD=xxxxxxxxxxxx

이것을 사용하는 것은 매우 간단합니다. 먼저 app레벨 build.gradle파일에 아래와 같이 local.properties을 불러들입니다.

// app level build.gradle
/**
 * Load local.properties
 */
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def googleMapApiKey = properties.getProperty('google.map.key')

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
( )

그리고, 이어서 같은 app 레벨 build.gradle 파일에 아래와 같이 local.properties에 설정한 값들로 채워 넣습니다.

signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            storeFile file(properties['MYAPP_RELEASE_STORE_FILE'])
            storePassword properties['MYAPP_RELEASE_STORE_PASSWORD']
            keyAlias properties['MYAPP_RELEASE_KEY_ALIAS']
            keyPassword properties['MYAPP_RELEASE_KEY_PASSWORD']            
        }
    }

마지막으로 중요한 것은, local.properties 파일은 git과 같은 버전 컨트롤에 추가하시면 안됩니다!

.gitignore 파일에 local.properties 파일을 추가하시면 됩니다. 리액트 네이브티 앱의 경우 기본적으로 포함되어 있습니다.

이 글은 여러분의 관심과 응원으로 제작되었습니다.


이타인클럽 - 우리 동네 도움 선순환 운동

Leave Android Signing Key Password 감추기 to:

Written by

이타인클럽 - 우리 동네 도움 선순환 운동

Read more #kr posts


Best Posts From etain

We have not curated any of etainclub's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From etain