Flutter로 개발한 앱 플레이스토어(Play Store)에 배포하기 (5) - App Bundle 빌드하기

Flutter로 개발한 앱 플레이스토어(Play Store)에 배포하기 시리즈


자 이번에는 앱 번들을 빌드해 보도록 하겠습니다.

사실 앱을 빌드하는 방식은 두가지가 있는데,

첫번째는 앱 번들 방식이며 두번째는 APK 방식입니다.

하지만 구글 플레이 스토어에서는 앱 번들을 이용하여 빌드한 방식을 추천하고 있으므로

이번 포스팅에서는 앱 번들을 이용한 빌드 방법을 소개해 보도록하겠습니다.


앱 번들 빌드

사실 앱 번들 빌드 방식은 엄청 간단합니다. 하지만 이 과정에서 오류가 많이 발생합니다.

이번 포스팅에서는이 오류가 발생하였을 때 해결하는 방법까지 같이 보도록 하겠습니다.

 

먼저 커맨드라인에서 [프로젝트 루트] 위치로 이동합니다.

 

 

그 후 아래 커맨드를 입력합니다.

 

flutter build appbundle

 

그럼 아래와 같은 사진처럼 결과가 나옵니다.

 

 

이것으로 앱 번들 빌드를 완료하였습니다.

어때요 엄청 간단하지 않나요??

그럼 제가 했던 삽질기를 같이 알아보도록 하겠습니다.


첫번째 삽질 - 런처 아이콘 확장자 오류

처음 앱 번들 빌드 커맨드를 입력했을 때,

이상한 오류가 발생하였습니다.

그 오류가 바로 밑과 같은 오류 입니다.

 

PS D:\programming\flutter\oneday_oneggang> flutter build appbundle
                                                                        
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> Multiple task action failures occurred:
   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-hdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.

        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-hdpi\ic_launcher.png: AAPT: error: file failed to compile.

   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.

        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png: AAPT: error: file failed to compile.

   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.

        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: AAPT: error: file failed to compile.

   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.

        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: AAPT: error: file failed to compile.

   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.

        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: AAPT: error: file failed to compile.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png: AAPT: error: file failed to compile.

   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.

        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: AAPT: error: file failed to compile.

   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.

        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: AAPT: error: file failed to compile.

   > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
      > Android resource compilation failed
        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.

        D:\programming\flutter\oneday_oneggang\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: AAPT: error: file failed to compile.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s

 

위 오류는 런처 아이콘의 확장자 때문에 발생하는 오류 입니다.

일전에 저희는 런처 아이콘을 app icon generator라는 사이트를 통해서 만들었습니다.

 

 

Flutter로 개발한 앱 플레이스토어(Play Store)에 배포하기 (1) - 런처 아이콘 만들기

같이보면 좋은 글 2020/03/31 - [프로그래밍 언어/안드로이드] - 안드로이드 Google Play Store 개발자 계정 등록 방법 2020/05/16 - [프로그래밍 언어/안드로이드] - OpenJDK 14.0.1 설치하는 법 새로 생성된 Fl..

noogoonaa.tistory.com

 

하지만 해당 사이트는 런처 아이콘을 생성할 때, 이미지 확장자를 .png라고 생성합니다.

그리고 저희는 그대로 그 .png 아이콘을 그대로 넣었습니다.

하지만 이렇게 넣으면 앱 번들 빌드 시 위와같은 오류가 발생하게 됩니다.

그렇기 때문에 우리는 .png 아이콘들을 아래 사진과 같이 확장자를 .PNG로 전부 바꿔야 합니다.

 

 

이렇게 하면 위 오류가 해결이 되는것을 알 수 있습니다.

 


두번째 삽질 - key.properties storeFile 경로 오류

이번 삽질은 key.properties에서 발생한 오류 입니다.

먼저 오류 내용을 봐 보겠습니다.

 

Removed unused resources: Binary resource data reduced from 192KB to 191KB: Removed 0%

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'D:\programming\flutter\oneday_oneggang\android\app\C:Usersbhj28key.jks' not found for signing config 'release'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 3s
* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'D:\programming\flutter\oneday_oneggang\android\app\C:Usersbhj28key.jks' not found for signing config 'release'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 3s

 

자 감이 잡히나요?? 그렇습니다.

 

 

key.jks 파일의 위치 경로가 비정상적이기 때문에 발생했던 오류 입니다.

해결 방법은 [android] - [key.properties] 경로로 이동합니다.

그 후 key.properties 파일 내용중 storeFile의 경로를 C:/Users/USERNAME/key.jks 에서C:\\Users\\USERNAME\\key.jks 로 변경해주세요

 

 

이렇게 하면 위 오류가 해결이 되는것을 알 수 있습니다.

 


마무리

오늘은 Flutter 앱 배포 그 다섯번째 앱 번들 빌드 방법을 알아보았습니다.

혹시 잘 안되는 부분이 있거나 포스트에 문제가 있다면 댓글을 남겨주시기 바랍니다.

감사합니다.

이 글을 공유하기

댓글