플러터 앱개발

디버그 모드로 서명한 APK 또는 Android App Bundle을 키를 생성 하고 Release 변경 하기

혼앱사 2023. 2. 11. 21:56
반응형
  • 앱출시할대 늘빼먹고 있어서 당황할때가 많다 그중에 디버그모드를 릴리지 모드로 전환하는것이다.
  • 아래 와같이 문구가 나오면 당황하지 말고 수정해서 다시올려보자
  • 디버그 모드로 서명한 APK 또는 Android App Bundle을 업로드했습니다. 출시 모드로 APK 또는 Android App Bundle에 서명해야 합니다. 서명에 관해 자세히 알아보기

 

key.properties 파일을 만든다.

storePassword=xxxxxxxxxxx
keyPassword=xxxxxxxxxxx
keyAlias=key
storeFile=c:\\Users\\xxxx\\xxxxxakey.jks

build.gradle 파일에서 아래 와같이 수정한다.

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
   // throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 33
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.shsoft.openchat"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        minSdkVersion 19
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('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
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
      • 그리고 
      • flutter build appbundle   실행해서 다시 빌드해서 올리면 문제없이 등록될것이다.
      •  
      •  
      • 암호화키 keytool을 이용한 jks 파일 제작은 구글링하면 금방 찾을수있다.
      • 인증서 생성(keytool설치후) keytool -genkeypair -keystore jks_keystore -storetype jks 인증서 출력 keytool -list -keystore my-keystore.jks

keytool -genkey -v -keystore legalbot.jks -keyalg RSA -keysize 2048 -validity 1000000 -alias legalbot

    •  
    • 페스트워드 없이 등록하면 바로 보여준다.  아래 SHA-256 코드로 firebase에 서명키로 등록하면된다.

728x90
반응형