개발 창고/Flutter

[Flutter] Android App Build (abb파일 만들기)

로이제로 2023. 5. 18. 22:00
반응형

1/ 런처 아이콘 생성

 - https://icon.kitchen/

 

각 해상도/기종에 맞는 아이콘을 제작하여 폴더에 추가해 줍니다.


2/ 앱 이름 설정 점검

생성하려는 어플명이 android/app/src/main/AndroidManifest.xml

<application
...
android:label="어플명"
...
>

3/ 앱 서명 키 생성

# Window
keytool -genkey -v -keystore c:/Users/[윈도우사용자명]/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

# Mac
keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

 

##########################
Enter keystore password:  (키 비밀번호)
Re-enter new password: (키 비밀번호 재확인)
What is your first and last name?
  [Unknown]:  (엔터)
What is the name of your organizational unit?
  [Unknown]:  (엔터)
What is the name of your organization?
  [Unknown]:  (엔터)
What is the name of your City or Locality?
  [Unknown]:  (Seoul)
What is the name of your State or Province?
  [Unknown]:  
What is the two-letter country code for this unit?
  [Unknown]:  (ko)
Is CN=garosucorp, OU=garosucorp, O=garosucorp, L=Seoul, ST=Unknown, C=ko correct?
  [no]:  (yes)
##########################

4/ 설정 파일 위치 변경 및 추가

- 생성한 키 파일을 android keystore 폴더로 옮겨줍니다.

※ keystore 내 폴더는 git에 올라가지 않도록. gitignore에 추가해 줍니다.

# 생성한 key 파일을 안전한 장소로 이동
$> mv ~/key.jks android/keystore/key.jks

- 키 비밀번호를 별도로 관리해 주는 keystore.password 파일을 생성해 줍니다.

# android/keystore/keystore.paasword 생성 및 작성
- key 비밀번호 관리용 파일 생성
(키 비밀번호)
# android/app/proguard-rules.pro 생성 및 작성
## Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }
-dontwarn io.flutter.embedding.**

5/ 설정 파일 적용

# android/app/build.gradle
- 추가한 설정 파일 들을 참조하도록 설정 변경
android {
...

    // [S] signingConfigs 설정
    signingConfigs {
        release {
            storeFile file('../keystore/key.jks')
            storePassword file('../keystore/keystore.password').text.trim()
            keyPassword file('../keystore/keystore.password').text.trim()
            keyAlias 'key'
        }
    }
    // [E] signingConfigs 설정

    buildTypes {
        release {
            // signingConfig signingConfigs.debug
            signingConfig signingConfigs.release    // release 속성으로 변경

            // [S] 코드난독화 및 사이즈 축소
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            // [E] 코드난독화 및 사이즈 축소
        }
    }
}


6/ 어플 버전 체크

# android/local.properties
...
flutter.versionName=1.0.0
flutter.versionCode=1


7/ Build

$> flutter build appbundle

# 안전하지 않은 플러그인이 있어서 옵션 추가
--no-sound-null-safety
$> flutter build appbundle --no-sound-null-safety

 

반응형