I've used this command
keytool -genkey -v -keystore ~/nutella.jks -keyalg RSA -keysize 2048 -validity 10000 -alias nutella
to generate a Keystore. It works fine but From what I've read this command should also prompt you for a key password(not the store password)? I never got this prompt.
I can run
keytool -v -list -keystore //nutella.jks
to see the contents of the Keystore. And the key seems to be there...ie the correct alias is there.
Where do I get/set the password for the the particular alias?
I have a key.properties in the android directory
storePassword=password
keyPassword=password
keyAlias=ballotbox
storeFile=/Users/gerardhorgan/ballotbox.jks
and in build.gradle I have:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "app.ballotbox.app"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
When I try to generate a release build I get
Execution failed for task ':app:validateSigningRelease'.
> Keystore file not set for signing config release
I think it might have something to with keyPassword because I didn't set this and read somewhere you can use the storePassword.
`
Try android, it's the default one.
May be the issue is with the wrong alias.
In this code you have mentioned -alias = nutella at the end.
keytool -genkey -v -keystore ~/nutella.jks -keyalg RSA -keysize 2048 -validity 10000 -alias nutella
But in key.properties you have keyAlias=ballotbox.
Secondly, as per official guide,
The -storetype JKS tag is only required for Java 9 or newer. As of the Java 9 release, the keystore type defaults to PKS12.
That means, if you don't provide -storetype JKS in the command to generate keystore, the generated keystore file is of type PKS12 and not JKS. It seems in PKS12 format you can only set store password and the same password is used for key password during build. So, when I had different passwords set in key.properties file for store and key, I was getting "given-final-block-not-properly-padded" error, and no error when both were same.
Related
I'm having a problem while running this command on Flutter: flutter build appbundle --target-platform android-arm,android-arm64,android-x64 which I need to run in order to execute flutter build apk.
build.gradle
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 keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
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
}
}
key.properties
storePassword=XXXX
keyPassword=XXXX
keyAlias=key
storeFile="C:/Users/User/Key/key.jks"
Error:
* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'D:\Projects\Flutter\iusefully\android\app\"C:\Users\User\Key\key.jks"' not found for signing config 'release'.
I finally found the answer,
my problem was in the key.properties file.
The problem occurred because I used storeFile="LOC"
The declartion of this variable for the path of the .jks should NOT be in " "
quotation.
WRONG:
storeFile="C:/Users/User/Key/key.jks"
RIGHT: storeFile=C:/Users/User/Key/key.jks
In addition, I added the key.jks file to the /app folder.
this solution work for me...
follow this instruction
https://flutter.dev/docs/deployment/android#create-a-keystore
and in key.properties don't put values inside ""
ex:
storePassword=454545
keyPassword=456565
keyAlias=upload
storeFile= C:/Users/{profile}/upload-keystore.jks
Change your key location c to d drive...
Same time permission issue occurred with c drive
For me it helped to rename file
{home}\.android\debug.keystore to {home}\.android\debug.keystore.jks
In addition to t0m3r's answer, when running the command below on windows: change USER_NAME to your user name
keytool -genkey -v -keystore c:\Users\USER_NAME\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload
Recently, we had to register a new upload key on our app in the google play store (internal track), though the setup seems a little different from our previous approach that requested a password on the key alias when creating a key using keytool on .jks format
We originally stored the storeFile & storePassword along with multiple key<Flavor>Alias & key<Flavor>Password in a keystore.properties file which worked fine, and our build.gradle looped over our product flavors assigning each signing config to the flavor.
Now though, when running this in the CLI as instructed by google play console to generate a new certificate:
keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks
keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks
the upload key was created, but it did not prompt for a key password.
So now I'm wondering how to build the app without having it signed when running the gradle bundle<Flavour>Release command?
For more clarity on our current setup:
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystorePropertiesFileExists && keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
signingConfigs { }
defaultConfig {
applicationId <application-id>
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
resValue "string", "build_config_package", <application-id>
}
flavorDimensions "default"
productFlavors {
Staging { applicationId "<application-id>.staging" }
RC { applicationId "<application-id>.rc" }
Production {}
}
buildTypes {
debug { signingConfig null }
release {
productFlavors.all { flavor ->
flavor.signingConfig = android.signingConfigs.create("${flavor.name}")
flavor.signingConfig.storeFile = rootProject.file(keystoreProperties["storeFile"])
flavor.signingConfig.storePassword = keystoreProperties["storePassword"]
flavor.signingConfig.keyAlias = keystoreProperties["keyAlias${flavor.name}"]
flavor.signingConfig.keyPassword = keystoreProperties["keyPassword${flavor.name}"]
}
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
debuggable false
}
}
We also use fastlane to handle our uploads with supply, are the specific commands (I can't see any) that would need to be amended for this?
Thanks!
I followed flutter.div instructions in how to deploy my app to google play, but im having a problem when i run flutter build appbundle in vs code, it says
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Failed to read key key from store "c:\Users\iikxz\upload-keystore.jks": No key with alias 'key' found in keystore c:\Users\iikxz\upload-keystore.jks
android/app/build.gradle:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
android/key.properties:
storePassword=123456
keyPassword=123456
keyAlias=key
storeFile= c:/Users/iikxz/upload-keystore.jks
If you just copied/pasted the command on the Flutter documentation, this one, keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload, then the alias would be upload and not key.
I am trying to build an android apk to share but, when installing I get the "App Not Installed" error message.
I have placed my credentials in the build.gradle file:
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.buddiesDrivers"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
signingConfigs {
release {
keyAlias 'key'
keyPassword 'abc123'
storeFile file('/Users/test/key.jks')
storePassword 'abc123'
}
}
I run the keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key option and ad the creds shown above then:
Flutter clean
Flutter Build APK
The build file creates the apk but, it cannot be installed. What did I miss?
Remove your previous installation, if it was the debug so it won't work usually. Uninstall that first then try installing the release version.
it could be because you have set minsdkversion to a higher version.
go to Android/app/build.gradle and change minsdversion to 19 or below.
it worked for me after trying all the solutions.
I create a key with this command :
keytool -genkey -v -keystore first-key.keystore -alias first-key-alias -keyalg RSA -keysize 2048 -validity 1000
and add this to gradle file :
signingConfigs {
release {
storeFile file('/home/mohamadreza/keys/first-key.keystore')
storePassword '1234567890'
keyAlias = 'first-key-alias'
keyPassword 'qq-2012'
}
}
buildTypes {
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
then I run this command:
cd android && ./gradlew assembleRelease
I got this error:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all task dependencies for configuration ':app:lintClassPath'.
> Could not find com.android.tools.lint:lint-gradle:26.4.2.
Searched in the following locations:
...
my classpath : classpath('com.android.tools.build:gradle:3.4.2')
how can I fix it?
This same issue I faced today.
I tried the following thing:
I deleted the output.json file from the folder
"yourProject/android/app/build/outputs/apk/release".
And RUN command to build the application.
It worked for me.
Hope will work for you too