kookmin-sw / capstone-2023-08

capstone-2023-08 created by GitHub Classroom
1 stars 4 forks source link

[FE] flutter 배포 #154

Closed lucyya99 closed 1 year ago

lucyya99 commented 1 year ago

참고사항

적다보니까 그냥 어미만 바꿔서 배포가이드로 올려도 되겠네요 😊 배포가이드를 적어야하긴 하지만, 미리 말씀드리자면 key.jks 파일과 key.properties파일은 공개하면 안돼서 따로 노션에 공유드릴예정입니다! .gitignore에도 추가했어요

  1. key.jks 파일은 android/app/에, key.properties 파일은 android/에 붙여넣어주시면 됩니다
  2. 터미널에서 저희 프론트 루트 파일 위치로 이동합니다 (client 폴더) - ex) C:\Users\[nickname]\capstone-2023-08\client>
  3. 설치하고 싶은 기기를 usb로 연결합니다
  4. 다음 두가지 명령어를 입력합니다
    flutter build apk
    flutter install
  5. 기기 선택

제가 usb로 연결한 기기 이름은 SM M536S입니다. flutter install을 입력하면, 무수한 선택창이 뜨는데 본인의 기기명을 찾아서 번호를 선택해주시면 됩니다

PS C:\Users\lucyy\merge_error\capstone-2023-08\client> flutter install
Multiple devices found:
SM M536S (mobile)            • RFCT50N6VYD   • android-arm64  • Android 13 (API 33)
sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.22621.1702]
Chrome (web)                 • chrome        • web-javascript • Google Chrome 113.0.5672.127
Edge (web)                   • edge          • web-javascript • Microsoft Edge 112.0.1722.48
[1]: SM M536S (RFCT50N6VYD)
[2]: sdk gphone64 x86 64 (emulator-5554)
[3]: Windows (windows)
[4]: Chrome (chrome)
[5]: Edge (edge)
Please choose one (To quit, press "q/Q"): 1
  1. 설치가 되면 이런 문구가 뜹니다
    Installing app-release.apk to SM M536S...
    Uninstalling old version...
    Installing build\app\outputs\flutter-apk\app-release.apk...        19.4s
  2. 어플 로고가 나타납니다!

실제 존재하는 어플들 사이에서도 기죽지 않고 있는게 너무 뿌듯하네요 디자이너님 덕분입니다!!!! ios도 배포가 가능할텐데 제 환경이랑 다르기도 하고 구색은 갖췄으니 여기까지만 할게요 하하

수정내역

레퍼런스에서 수정한 목록입니다!

1. key.properties 파일이 android/app/가 아니라 android/에 있어야 합니다

2. key.properties 파일을 자꾸 못찾길래 이것도 바꿔주었습니다

변경전

signingConfigs {
        release {
            storeFile file(keystoreProperties['storeFile'])
        }
    }

변경후

signingConfigs {
        release {
            storeFile file("key.jks")
        }
    }

3. targetSdkVersioncompileSdkVersion을 33으로 맞춰주었습니다

밑의 4번 오류를 해결하면서 바꾸게 되었습니다! 갤러리에서 사진 고를때 쓰는 패키지인 ImagePicker가 33 버전을 선호한다고 경고문구에 적혀있더라구요

android {
    compileSdkVersion 33
    ...
    defaultConfig {
    ...
        targetSdkVersion 33
    }
}

4. android/build.gradle 파일에서 해당 부분을 바꿔주어야 합니다

recompile with -Xlint:deprecation라는 오류가 났었는데, Kotlin 버전이 안맞아서 생기는 문제라고 합니다

변경전

allprojects {
repositories {
        google()
        mavenCentral()
}

변경 후

allprojects {
    gradle.projectsEvaluated {

        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:deprecation"
        }
    }

    /*repositories {
        google()
        mavenCentral()
    }*/
}

5. android/gradle/gradle-wrapper.properties 파일에서 해당 부분 변경

아주 사소한 차이인데 이것도 고쳐주라고 경고 문구가 뜨더라구요.. 변경전

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

변경후

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip

6. 전부 변경 후 flutter build apk --split-per-abi가 아닌 flutter build apk로 빌드

7. proguard는 그냥 안씁니다 오류가 너무 나요

/*            // start of 코드난독화 및 사이즈 축소
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            // end of 코드난독화 및 사이즈 축소*/