본문 바로가기
ETC/Flutter

[flutter] 앱 서명하기 (apk 추출하기 1 of 3)

by 안주형 2021. 10. 18.

앱 서명하기

1.keystore 만들기

keytool -genkey -v -keystore ~/파일명.jks -keyalg RSA -keysize 2048 -validity 10000 -alias 지정할이름 -storetype JKS
  • ~/는 생성될 디렉터리 주소이다.
  • -alisa는 후에 설정해줄 alisa의 이름이다.

각 질문에 대한 내용은 아래와 같다.

Q > What is your first and last name? 당신의 첫번째와 마지막 이름은 무엇인가요?
A > AhnJuHyeong

Q > What is the name of your organizational unit? 당신의 부서의 이름은 무엇인가요?
A > solo

Q > What is the name of your organization? 당신의 조직 이름은 무엇인가요?
A > solo

Q > What is the name of your City or Locality? 당신의 도시 이름은 무엇인가요?
A > Busan

Q > What is the name of your State or Province? 당신의 지역 이름은 무엇인가요?
A > Korea

Q > What is the two-letter country code for this unit? 당신의 국가 코드를 입력해 주세요
A > 82

Q is ~~~~ correct? 
A > yes 혹은 Y

Keystore 참조하기

  • 앱을 빌드할 때 앱이 Keystore를 참조해야 하므로 우리는 안드로이드에 특정 명령어를 입력해야 한다.
  • 먼저 배포할 앱 프로젝트 폴더에 접근한 후 android 바로 하위 폴더에 key.properties 이라는 파일을 생성한다.

imageimage

  • 그 후, 아래의 내용을 key.properties에 입력해 준다.
  • storePassword=이전에 입력한 비밀번호 keyPassword=이전에 입력한 비밀번호 keyAlias=이전에 입력한 Alias storeFile=파일명.jks
  • 이때 key.properties 는 공개된 저장소에 업로드하면 안 되고 개인이 보관해야 한다.

Grandle에서 서명 구성하기

  • AndroidGrandle 에서도 해당 key.properties 파일에 접근할 수 있도록 설정해야 한다.
  • android - app - build.gradle 에서 아래와 같이 바꿔준다.
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

------ 이 위에 위 코드를 삽입
android{
...
}
   signingConfigs {
       release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
       }
   }

   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }

댓글