Android sign apk from gradle issue - android

I used android studio to generate sign APK (build->generate sign APK).
both V1 and V2 checkboxes were marked in the signature version.
To upload an APK via CI-CD, I am running assemleRelease cmd.
The problem is that the sign from assembleRelease is different (probably it's signed with V1 only).
How can I run assembleRelease to sign with the same signature as android studio (build->generate sign APK)?
my code:
android {
signingConfigs {
release {
storeFile file('../config/xx.jks')
Properties props = new Properties()
props.load(new FileInputStream(file("../local.properties")))
storePassword "password"
keyAlias "my-alias"
keyPassword "password"
v2SigningEnabled true
}
debug {
storeFile file("../Config/xx.keystore")
}
}

My mistake, The path from the studio linked to another key-store file (not the one the "storeFile file('../config/xx.jks')" linked to..

Related

APK release not update installed AAB app from Play Store

I have installed previous version of my app from Google Play Store.
Now, I make an apk release with the same keystore file with gradlew assembleRelease command or with android studio, and try to install it manually in device or with gradlew installRelease on emulator.
But every time I got App not installed error.
I got this on LOGCAT:
INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.myapp.myapp signatures do not match previously installed version; ignoring!
I use enableSeparateBuildPerCPUArchitecture in my gradle file.
and also I enable v2 signing with these commands in gradle file (in release section of signingConfigs):
signingConfigs {
debug {
storeFile file(...)
storePassword ...
keyAlias ...
keyPassword ...
}
release {
storeFile file(...)
storePassword ...
keyAlias ...
keyPassword ...
v1SigningEnabled true
v2SigningEnabled true
}
}
NOTE: Also if I install the previous version of my app manually, the Play Store won't update it.
This is the expected behaviour.
This is because the keystore signatures don't match, as most likely you have opted in for your signing key to be managed by Google. You will have to uninstall the previous app before installing the new version if it comes from a different source (Google Play/ Android Studio build).

Is there a way to set a permanent SHA-1 key for android studio project?

I made this Android app that fetches some data using AI Platform Training & Prediction API from Google Cloud Platform. For this app to work it needs to be approved by GCP using SHA-1 Fingerprint certificate. I am making this app as an assessment for module Im taking at the university, so, when the teacher will open my Android Studio project it will have a different SHA-1, so the app will not fetch the data...
Any Ideas how I might be able to maybe set a permanent SHA-1 key for my project, so when the teacher will open the project, Android Studio will not generate a new one?
Thank you!
The SHA-1 is based on the app signature. Since this is for a project I suggest you do the following (never do this in a production app).
Create a new signing key (Build -> Generate Signed Apk -> APK ->
Create New)
Move the signing key to your project's folder
Add this to your app.gradle
android {
signingConfigs {
debug{
storeFile file("your_key.keystore")
storePassword 'password'
keyAlias 'alias'
keyPassword 'password'
}
release {
storeFile file("your_key.keystore")
storePassword 'password'
keyAlias 'alias'
keyPassword 'password'
}
}
}
EDIT: Forgot to mention, run the signingReport gradle task after you do this to get your new SHA-1 that you have to add to your project.
after creating the .keystore file and running the report I get the new SHA-1 key, but the build fails. I get this:
Entry name 'play-services-ads-identifier.properties' collided

failed to release a signed APK on Android Studio

I am working on a project and when I try to release a signed APK from build.Gradle it gives me this error :
Error:(20, 0) C:\Users\sephn\Downloads\Fingerprint2Sleep-master\signing.properties (The system cannot find the file specified)
Open File
Here is my SigningConfigs:
signingConfigs {
release {
def File signingConfFile = file("../signing.properties")
def Properties signingConf = new Properties()
signingConf.load(new FileInputStream(signingConfFile))
storeFile file(signingConf['C:\\Users\\sephn\\Downloads\\APKs & JKSs\\FingerPrintQuickie.jks'])
storePassword signingConf['MyPassword']
keyAlias signingConf['MyKey']
keyPassword signingConf['MyPassword']
}
}
Try removing all uses of signingConfig and signingConfigs in your build.gradle file. And instead, consider using Android Studio -> Build -> Generate Signed APK, and enter your credentials manually.
Sometimes gradle-based signing scripts do not always work. See also: Android Studio 2.2 - Can no longer create unsigned release builds - "validateSigningReleaseLive FAILED"

Android : "Keystore was tampered with, or password was incorrect" after migrating from Eclipse to Android Studio

I've been developing my project in Eclipse IDE. The app is submitted on Play Store, and I've published a couple of versions updates successfully.
Recently I've migrated to Android Studio (and gradle, of course). I've done some changes to the project code base, including min and target sdk changes, but package name remains the same. The project is successfully compiled and debug app is successfully assembled and running ok.
But now I can not assemble a release version because of :
Keystore was tampered with, or password was incorrect
The keystore have not changed, and I do know it's password.
I've set signingconfigs in build.gradle:
android {
...
signingConfigs {
release {
storeFile file("keystore/motolife.keystore")
storePassword "***"
keyAlias "motolife"
keyPassword "***"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
...
}
I've tried also to sign using jarsigner:
jarsigner -verbose -keystore keystore/motolife.keystore build/outputs/apk/motolife-new-debug.apk motolife
But no luck.
I've even installed gradle support for Eclipse and tried to assemble signed release app , but got the same "Keystore was tampered with, or password was incorrect" error.
try doing something like this then:
release {
storeFile file("keystoreName.keystore") //change value per signing
def pass = System.console().readPassword("\nPlease enter key password: ")
pass = new String(pass)
storePassword pass
keyAlias "revision3" //need to change these values per signing
keyPassword pass
}

How to set debug.keystore for each android project?

I'm developing some applications that need system UID. So I made a special keystore file "PFDebug.keystore" made from AOSP's platform.pk8 and platform.x509.pem.
I set it in Eclipse >window >preferences >android >build >cutstom debug keystore. That works fine.
But I am also developing non-privileged applications that use my own debug.keystore file. So I have to change keystore file for each build. I know that default debug.keystore is used when I set blank.
How can I bind debug keystore files for each android project?
It's doable with gradle.
For each project you have a build.gradle in which you can specify a signingConfig. Like that :
signingConfigs {
debug {
storeFile file("../debug.keystore")
}
release {
storeFile file("../prod.keystore")
storePassword 'prod'
keyAlias 'prod'
keyPassword 'prod'
}
}

Categories

Resources