Search code examples
androidgradlefirebase-test-lab

Android package test does not have a signature matching the target


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!


Solution

  • 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:

    1. Run on different machines
    2. 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.