nonani

Flutter 앱 배포 - (1) 본문

flutter

Flutter 앱 배포 - (1)

nonani 2024. 4. 29. 18:04

공모전을 준비하면서 앱을 직접 배포해보게 되었다. 앱 배포 절차에 대해 알아보자

    개발 환경은 Mac OS이다.

     


    요약

    1. jks file 생성
    2. build.gradle 설정
    3. release APK/ABB 생성

     


    Generating jks file

     

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

    위의 코드를 터미널에 입력하면 초기 비밀번호를 설정하라는 명령어가 뜨고 몇몇 질문에 답변을 입력해주면 된다. 자신의 이름, 소속 등을 물어본다. 

    이후에는 key.jks 파일이 생성되는 것을 확인할 수 있을 것이다. 이를 android/app/ 경로로 옮겨준다.

    이후 같은 경로에 key.properties 파일을 만들어주고 아래와 같이 입력해준다.

    storePassword=<내가설정한password>
    keyPassword=<내가설정한password>
    keyAlias=key
    storeFile=./key.jks

     


     

    build.gradle 설정

    android/app/build.gradle 파일을 찾아서 아래와 같이 코드를 수정해준다.

    def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('app/key.properties')
    if (keystorePropertiesFile.exists()) {
        keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }
    
    
    // ....
    
    // ....
    
    
    
    signingConfigs {
            release {
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
                storeFile file(keystoreProperties['storeFile'])
                storePassword keystoreProperties['storePassword']
            }
        }
    
        buildTypes {
            release {
                // TODO: Add your own signing config for the release build.
                // Signing with the debug keys for now, so `flutter run --release` works.
                signingConfig signingConfigs.release
            }
        }

     


     

    release APK/ABB 생성

    터미널에 flutter build appbundle 입력

     

     


     

    마무리

    그러면 끝이다. 쉽다.

     

    'flutter' 카테고리의 다른 글

    소셜 로그인 - 카카오 (1)  (0) 2022.12.15