前提・実現したいこと
Flutterでアプリを作成したのでAPKにbuildしようとしたのですが、
KeytoolExceptionが発生してbuildが失敗してしまいます。
恥ずかしながら--stacktraceオプションの付け方もよくわからず、その辺りも教えていただけると助かります。
発生している問題・エラーメッセージ
Building with sound null safety FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:packageRelease'. > A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable > com.android.ide.common.signing.KeytoolException: Failed to read key key from store "C:\Users\●●●\android\app\key.jks": Invalid keystore format * 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 23s Running Gradle task 'assembleRelease'... Running Gradle task 'assembleRelease'... Done 24.4s Gradle task assembleRelease failed with exit code 1
該当のソースコード
C:\Users\●●●\android\build.gradle
buildscript { ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { google() jcenter() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } task clean(type: Delete) { delete rootProject.buildDir }
C:\Users\●●●\android\app\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" def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } android { compileSdkVersion 30 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.example.●●●" minSdkVersion 16 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } signingConfigs { release { storeFile file("key.jks") storePassword "hogehoge" keyAlias "key" keyPassword "hogehoge" v1SigningEnabled true v2SigningEnabled true } } 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" }
C:\Users\●●●\android\app\key.jks
バイナリなので記載しない
C:\Users\●●●\android\gradle\wrapper\gradle-wrapper.properties
#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
試したこと
以下のコマンドを入力
flutter build apk --release
profileの作成後上記のコマンドを入力
flutter build apk --profile
gradleのダウングレード
4.1.0→3.5.0
補足情報(FW/ツールのバージョンなど)
Flutter version 2.0.3
openjdk version 16.0.2
gradle version 4.1.0
あなたの回答
tips
プレビュー