Huawei Push Kit - com.huawei.hms.common.ApiException: 6003: certificate fingerprint error - huawei-mobile-services

I received a "push token failed, com.huawei.hms.common.ApiException: 6003: certificate fingerprint error." I don't know what's going on here.

Check your keystore signing configuration in the app-level build.gradle file. You need to make sure that the debug and release signing configs are configured properly.
signingConfigs {
debug {
storeFile file(DEBUG_STORE_FILE)
storePassword DEBUG_STORE_PASSWORD
keyAlias DEBUG_KEY_ALIAS
keyPassword DEBUG_KEY_PASSWORD
}
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
}
}

Related

Why should we load keystore variables from key.properties instead of env variables?

To build and release a Flutter app, it's recommended that the keystore properties be stored in a file called key.properties:
storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=upload
storeFile=<location of the key store file, such as /Users/<user name>/upload-keystore.jks>
and then in the build.gradle file, the values are loaded from that file:
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 {
signingConfig signingConfigs.release
}
}
Why don't we simply load the keystore properties from the system env variables? Like this:
signingConfigs {
release {
keyAlias System.getenv("keyAlias")
keyPassword System.getenv("keyPassword")
...
}
}
This way, we will be also able to load those values from GitHub secrets when building the apk file in GitHub Actions. So what's the point or benefit of having a key.properties file?

Flutter build appbundle failed

I'm trying to build my flutter appbundle but I got an error saying:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file '/Users/user/key.jks' not found for signing config 'release'.
Here is my release in build.gradle:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
Is there a way to fix this?
Looks like your keystore file path is not valid and as I don't know where you put your key.jks file then you may follow these steps.
Move/paste your key.jks file inside your project's {project-root}/android/app/
Create keystore properties file key.properties in your project's {project-root}/android module and use this code and replace **** with your value/keys
storePassword=****
keyPassword=*****
keyAlias=****
storeFile=./key.jks
Open {project-root}/android/app/build.gradle and paste this code inside signingConfigs
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
Add this block before android section in app/build.gradle
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
here is the documentation how you implement
https://docs.flutter.dev/deployment/android

Execution failed for task ':app:signReleaseBundle'

I have this error at the moment to make flutter build appbundle
this is the error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Failed to read key sd from store "C:\flutter_project\cursin2\cursin-main\android\app\upload-keystore.jks": Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available
* 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 6s
Running Gradle task 'bundleRelease'... 9,1s
Gradle task bundleRelease failed with exit code 1
PS C:\flutter_project\cursin2\cursin-main>
i've tried all ways to fix it, but the error is still appearing.
my key.properties:
storePassword=ul109000
keyPassword=ul109000
keyAlias=sd
storeFile=C:/flutter_project/cursin2/cursin-main/android/app/upload-keystore.jks
in android app/ build.gradle
inside android tag
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
signingConfigs {
debug {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
storeFile path will be ./upload-keystore.jks
and
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
minifyEnabled true
shrinkResources true
signingConfig signingConfigs.release
}
}
The only method to solve this, that worked for me was:
flutter clean
edit the path i used in key propeties.
For example: "./upload-keystore.jks" to "C:/key/myapp/upload-keystore.jks"
3. flutter build appbundle
Delete this:
debug {
storeFile file(storeFile_)
storePassword storePassword_
keyAlias keyAlias_
keyPassword keyPassword_
}
First
in android app/ build.gradle
replace this
buildTypes {
release {
signingConfig signingConfigs.release
}
}
with this
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
minifyEnabled true
shrinkResources true
signingConfig signingConfigs.release
}
}
Second
remove upload-keystore.jks in your generation path in my case (Ubuntu OS)
the path is /home/user/upload-keystore.jks
Third
genrate a new key with with extra attribute
-storetype JKS
for Linux
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload -storetype JKS

Flutter Android Studio Error: couldn't get unknown property 'keystoreProperty'

I'm new to flutter and I'm trying to run my first project without any changes to the source code of the demo app. But I keep getting the following error:
Launching lib\main.dart on SM A115F in release mode...
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\METRO\StudioProjects\helloworld\android\app\build.gradle' line: ??
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not get unknown property 'keystoreProperties' for SigningConfig_Decorated{name=release, storeFile=null, storePassword=null, keyAlias=null, keyPassword=null, storeType=pkcs12, v1SigningEnabled=true, v2SigningEnabled=true, enableV1Signing=null, enableV2Signing=null, enableV3Signing=null, enableV4Signing=null} of type com.android.build.gradle.internal.dsl.SigningConfig.
* 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 5s
Exception: Gradle task assembleRelease failed with exit code 1
I tried everything from upgrading gradle to generating keystore even if I'm just trying to run the project,
this is my app\build.gradle file:
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 FileNotFoundException("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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.helloworld"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName.toString()
}
signingConfigs{
release {
keyAlias keystoreProperties['key']
keyPassword keystoreProperties['key password']
storeFile keystoreProperties['C:\\Users\\METRO\\key.jks'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['store password']
}
}
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 '../..'
}
if (project.hasProperty("MyProject.signing")
&& new File(project.property("MyProject.signing")+".gradle").exists()){
apply from: project.property("MyProject.signing")+".gradle"
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()){
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
And this is my keystore.properties file :
storePassword = store password
keyPassword = key password
keyAlias = key
storeFile = C:\\Users\\METRO\\key.jks
Note: android studio highlights warnings in front of storePassword,keyPassword,keyAlias as unused properties. Is this is the problem ? If it is, how to solve it ? PLEASE help.
You seem to have misconfigured your app\build.gradle file and used double back slashes on your keystore.properties.
Add this at the end of your localProperties instead of the bottom of that file.
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
Change your
signingConfigs{
release {
keyAlias keystoreProperties['key']
keyPassword keystoreProperties['Kha128256512$']
storeFile keystoreProperties['C:\\Users\\METRO\\key.jks'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['Kha128256512$']
}
to
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ?
file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
and run this on Terminal
keytool -genkey -v -keystore
c:\Users\YOUR_PREFERRED_LOCATION\upload-keystore.jks -storetype JKS
-keyalg RSA -keysize 2048 -validity 10000 -alias upload
and make sure you set your location like this in your key.properties file
storeFile=c:/Users/YOUR LOCATION/upload-keystore.jks
You probably missing this block inside project/android/app build.gradle file:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
It should be just before Android block:
follow the steps and you will get rid of the problem:
Flutter signing the application
You probably have misconfigured the file and the credentials too.

Sign two buildTypes with the same certificate

I have an app that has 2 product flavors, p1 and p2
and two build types, debug and release
when i run the app p1Release or p2Release in android studio, they are each signed with the release certificate.
But when I run p1Debug it's signed with the debug certificate.
However I want p1Debug to be signed with the release certificate.
I've tried the following:
android {
...
defaultConfig {
...
}
productFlavors {
p1 {
signingConfig signingConfigs.release
}
p2 {
signingConfig signingConfigs.release
}
p3 {
signingConfig signingConfigs.debug
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
}
release {
debuggable false
}
}
Here I expect whenever I build p1Debug from AndroidStudio to have it signed with the release certificate.
But that does not happen.
but when I run p1Release it is signed with the release certificate.
How do I fix it for p1Debug ?
*note when i do : Build -> Generate signed apk -> and select the correct configuration, it does sign it correctly.
But i need it to work when i click the run button
in general:
buildTypes {
debug {
signingConfig signingConfigs.release
}
}
if you want the flavor signing config to take over:
buildTypes {
debug {
signingConfig null
}
}