Android package test does not have a signature matching the target - android

There are many similar question about the app signature, like this.
But none are my case.
I used to have a CI that run ./gradlew :App:assembleDebug :App:assembleAndroidTest
To save time I try to parallelise both assemble commands in two different jobs/pipelines
./gradlew :App:assembleDebug and ./gradlew :App:assembleAndroidTest
But now, I got this error from Test Lab:
com.company.debug.test does not have a signature matching the target com.company.debug
How/why the signature changes when I'm compiling in another instance? The solution is clear, just put both together again. But I'm looking to understand this Android/Gradle behaviour of signatures.
Thanks!

Debug builds are signed with the debug key, which is generated by the Android tools on each machine. The key is stored in the user home directory. I.e. by default each machine has a different debug signing key, which is not compatible with each other.
My guess is that your CI jobs/pipelines do one or both of two things:
Run on different machines
Generate a new debug key for each job, as you do not share the machine environment
A possible solution is to include a debug key as part of your repository and configure gradle to use that key for signing:
android {
...
signingConfigs {
debug {
storeFile rootProject.file('debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
}
...
}
You can find more details in this Stackoverflow question, and the official Android app signing documentation.

Related

Google maps does not show up when uploading it

So i tried a lot of suggestions online, saw a lot of people have similar problems with it.
So i signed the app for release, generated to keys( understood is better to add to the google maps api release.xml a different key from the debug one) and added the sha1 for the release on console google play after my keystore, still no results.
The only thing i observed and may be a solving is when i am trying to run the app i get the error(1) that states my app is not signed. And found online that i need to go to project structure and sign it -> build types->release -> chose my config. but after i press ok the config dissapears and gradle(3) remains unchanged. ( Would like to mention that in the Project structure i get 2 errors about my SDK/ NDK(2) that says their location should`t contain white spaces but i understood there is no real problem)
Please help, i`ve tried everything i could find.
Thank you,
Daud.
Maybe you can define your signingConfigs in your gradle file manually?
Something like this:
signingConfigs {
config {
keyAlias 'YourKeyAlias'
keyPassword 'YourKeyPass'
storeFile file('./yourKeyStore.jks')
storePassword 'yourStorePass'
}
}
and specify your configuration in buildTypes:
release {
...
signingConfig signingConfigs.config
...
}

How to make multiple workstations build app compatible on one Android device

I have multiple android dev workstations and I work on them to build Android apk and deploy them on one Android device. Whenever I change a workstation, I have to remove the app from the device and reinstall it with a new one. So all caches are removed after reinstall. I wonder whether there is a way for me to deal with multiple workstations sharing with one android device without reinstall. I think there must be something unique across multiple workstations.
This happens because different workstations have different debug keystore. You can achieve your intended behavior as follows:
You can create your own keystore (follow this SO for creating it), check it in your repository. Place this keystore in your project directory.
Change your debug config to use this new keystore. This will ensure your debug app is signed with same keystore across all your dev workstations
To do that change your build.gradle as follows:
android {
...
signingConfigs {
defaultConfig {
storeFile file(getRootDir().getPath() + "\<file-name>.keystore")
storePassword <your password>
keyAlias <your alias>
keyPassword <your password>
}
}
buildTypes {
debug {
signingConfig signingConfigs.defaultConfig
...
}
}
}
Commit the code and perform pull across all your dev workstations.

How to copy the debug.keystore file?

I have the same problem with Android Google Maps not working outside my computer, and in the solution, it looks like making sure everyone in my team have the same .keystore file will solve the problem. However, .keystore file is hidden, I guess it's also encrypted in some way that you can't just view it using cat command.
I am working with my teammates on a android project and I'm in charge of the map part, but no one else can see the map even if we have the exactly same codes(shared using git).
So could anyone please tell me how to copy the file to others (and is it safe to do so)?
Or is there any other ways to do this?
I use a mac, the I have teammates using windows and mac.
Option a)
You can make everyone on your team use the same signing key for debug builds.
I like this solution because when testing you can easily update already installed apps from your colleagues (because the signatures match).
1. Make a prepro keystore
Copy one of your debug keystores in your project root directory. Debug keystore is typically located in ~/.android/debug.keystore. Let's name the copy prepro.keystore.
2. Make a prepro signing config
In your app module build.gradle create a new signing config that's using the keystore from step 1.
android {
signingConfigs {
prepro {
storeFile rootProject.file("prepro.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
}
Note the passwords and key alias for all debug keystores.
3. Use the prepro signing config
Make all your debug builds use this new signing config.
android {
buildTypes {
debug {
signingConfig signingConfigs.prepro
}
}
}
Notes
You can name your new signing config anything except debug and release.
is it safe to do so
Putting a key in Git is OK as long as it's a key intended for development.
Option b)
Add your colleagues' debug key signatures to the project Google console. Then apps built by them will be able to use Google APIs such as Maps.
More info here: https://developers.google.com/maps/documentation/android-api/signup#getting-the-certificate-information-yourself
I guess it's also encrypted in some way that you can't just view it using cat command.
Correct, see the link above.

Android) Application Signature of weChat developers. What value do I put in it?

I want to get the wechat login data.
Due to the problems of Application Signature, I had once failed.
Please tell me how to put a value on what 'Application Signature'.
Thanks.
Check out this example code I found on github.
For the signature, use the MD5 hash of the key used to sign your
published APK. The easiest way to do this is to setup a signature to
always use for your debug/release builds. If you have a java keystore
holding a signing key within your project, you can add the following
to your app gradle file to sign your debug release with a constant
signature:
android {
...
// Keystore located in root project folder. Google can show many examples on how to generate keystores with signatures
signingConfigs {
debug {
storeFile file('keystore.jks')
storePassword 'password'
keyAlias 'weChatDebug'
keyPassword 'password'
}
}
... }
An easier way would be to:
download this app by following this link.
Install the app you want to generate the signature of (the app has to be signed)
Open the app you downloaded in step 1, fill in the name of the package of the app you installed in step 2 and click the button
A signature will be generated for you
You have to put MD5 of your keystore. Keystore will be the one with whom you are signing your APK.

Import key store from eclipse to android studio

I made research on the topic, but couldn't find a solution:
I created a signed apk from an eclipse project, and i also have the eclipse key store.
But i couldn"t find out how to import this key store at signing in Android Studio.
These are the following things i already tried:
-adding the key store path as it was created originally by eclipse in Android Studio
-adding the path in Android Studio after adding the .jks extension to the original file
In both cases the error is:
Execution failed for task ':application:packageRelease'.
Failed to read key from keystore
So what is the correct way of adding an eclipse keystore to Android Studio?
Any suggestions appreciated, because i have no idea what goes wrong.
I believe this message means that your key alias does not exist. In Android Studio, you can use Build > Generate Signed APK..., enter your key store password, and then browse for a list of key alias in the keystore.
I had the same problem and was really frustrated with it. I have solved it and can help you with it.
1) Ensure that your key is uncorrupted and untampered. This is the reason behind most of the problems.
2) Select the path of the key in "Generate Signed APK" dialog box. This path can be anything, it doesn't actually matter.
3) Now just put your keystore password. This needs to be correct, otherwise you will get messages like "Keystore is corrupted", but it isn't.
4) After entering the password, select the Key Alias. If you enter wrong password, this field will be blank.
5) Put the Key Password same as Keystore password. This worked perfectly for me.
Hope it helps all of you. Thanks.
This is specified in your Gradle build file, copy the keystore file into your Android Studio project structure, I chose to create a new directory under app called keystores: /app/keystores/release.keystore
signingConfigs {
debug {
storeFile file('keystores/debug.keystore')
}
release {
storeFile file('keystores/release.keystore')
keyAlias ...
storePassword ...
keyPassword ...
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
debuggable true
}
release {
signingConfig signingConfigs.release
debuggable false
}
}

Categories

Resources