The uploaded APK does not have valid signature Firebase TestLab instrument test type
Asked Answered
J

8

20

I'm trying to testing with my demo app with firebase test lab with instrument test type but i'm not able to test that due to following error regarding to apk. enter image description here

I uploaded the debug-keystore signed apk there. Even in my other project i also uploaded my own keystore signed apk there with my androidTest.apk but same error is showing. Please guide me if i'm missing some major steps. Thanks

Jermyn answered 31/10, 2019 at 10:30 Comment(9)
is this a v1 or v2 signature? Is APK have debuggable true in build.gradle?Weakness
@Prashant Sable Yes i tried with v1 and v2 signature also with debuggable flag true in release build type. But my Android Test apk app-debug-androidTest.apk is default one that generate when we run instrument locally on device.Jermyn
Debuggable flag should be false and not true while uploading the APK.Weakness
@Prashant Sable i tried with debuggable flag false but same result. app-debug-androidTest.apk also need to signed with my own keystore rather then default android keystore?Jermyn
You should not use debug keystore to upload the apk. Create new release key store and use to sign the APKWeakness
@Prashant Sable I've already tried to upload my app apk with my own signed keystore on firebase console. Are you asking about androidTest.apk file to signed with my own keystore?Jermyn
Yes it should be signed.Weakness
I tried with both options but error same on firebase console.Jermyn
Check my answer below.Weakness
P
15

I came across the same issue. I tried uploading different versions of APKs - signed, not signed, from the build\outputs\apk, combined test with the release APK - nothing worked.

The way I got it to work was by running the instrumentation tests on the Firebase Test Lab Device Matrix from Android Studio (see here for steps https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests#run-ctl). Then it turns out Android Studio generates valid APKs in:
build\outputs\apk\debug\-debug.apk
build\outputs\apk\androidTest\debug\-debug-androidTest.apk

Then when you upload those generated everything works fine.

Just as as a tip - if you don't want the test to actually run from Android Studio but only to generate the APKs (I prefer to run them via the firebase website because it offers a better control over what devices, locales etc.), you can define it to run it on a non-existing combination of a device and API level e.g. Emulator Pixel 2 and API level 25. If you do that Android Studio will generate the APKs but will not actually run - meaning as far as I can see it will not decrease your daily free quota :).

Palm answered 8/12, 2019 at 13:15 Comment(1)
Nowhere on this link "Building Instrumented Tests" does it show how to configure for signing the androidTest apk. How did you achieve signing of the test APK?Hedgepeth
P
11

I build both apks via AndroidStudio > Gradle and it works for me.

enter image description here

Choose:

  1. assembleDebug
  2. assembleAndroidTest

Then find apk in packages:

  1. ...\app\build\outputs\apk\myFlavor\debug
  2. ...\app\build\outputs\apk\androidTest\myFlavor>\debug

(Take a look at the date of the apk, just to make sure this is the one that was just built)

Then simply upload those apks to Firebase Test Lab

BTW, running via Android Studio > Edit Configuration...> Target > Firebase Test Lab Device Matrix works as well.

Porterhouse answered 20/1, 2020 at 14:14 Comment(2)
I've had to generate a signed APK, which is located in app/release/ afterwards.Rennold
Worked for me! However if you have multiple flavors it looks like any assembleXXX task will compile code for all flavors. If you only need to compile code and tests for one flavor go to the other group instead of build, and there you'll find more "precise" tasks like assembleDemoDebug, assembleDemoDebugAndroidTests etc.Cthrine
W
7

Firebase is having variety of devices. Signature V2 is introduced in Android 7. If apk is getting installed in lower devices it might required v1 signature. While generating your apk, select v1 signature in options. Signing with v1 might help. enter image description here

Weakness answered 31/10, 2019 at 12:28 Comment(1)
I know already this. I tried with these option too. I only selected google pixel device with api level 28 but the error is same :( .Jermyn
I
3

I came across the same issue, and the problem was in the test APK signature (looks like Firebase requires both APKs to be signed). Apparently, it was not signed because of I was testing a library module instrumented tests. The first thing I would suggest is to go and check signatures for both APKs:

jarsigner -verify APK_FILE_PATH

If you see that one of your APKs is not signed, you need to dig dipper into your project setup. If you want to test a library module, you might be missing signingConfigs in build.gradle of this library (usually it's not there if you serve the library only as a part of your main application). It seems that Firebase is totally fine with DEBUG versions of the app and test APKs, so you may just need to have a debug.keystore signing in the library build.gradle:

android {
    ...
    
    signingConfigs {
        debug {
            storeFile file(PATH_TO_YOUR_DEBUG_KEYSTORE)
        }
    }
}

Importance answered 11/10, 2020 at 17:13 Comment(0)
T
1

I've met the same problem, but I solved the problem as follows:

  1. add android:testOnly="false" in your AndroidManifest.xml
  2. rebuild the apk

you can test the built apk in the terminal: adb install xxx/xxx.apk if you can install it successfully on your phone. It means the apk is ok, then you can upload your apk to firebase Test lab.

Transparent answered 9/6, 2020 at 13:31 Comment(0)
Z
1

I Know it too late. But the solution that works for me is to

  1. Clean the Android Studio Project.

  2. Build Apk.

  3. Upload the Apk to the Test lab.

Hope it works.

Zirconia answered 15/2, 2021 at 11:13 Comment(0)
I
0

I needed to build a signed apk for our development env, so in android/app/build.gradle I added:

    signingConfigs {
        config {
            keyAlias 'someKeyAlias'
            keyPassword 'somePassword'
            storeFile file('../keystores/debug.keystore')
            storePassword 'somePassword'
        }
    }
        development {
            initWith release
            applicationIdSuffix '.development'
            versionNameSuffix '-DEVELOPMENT'
            matchingFallbacks = ['release']
            signingConfig signingConfigs.config
        }

in /android/, run ./gradlew assembleDevelopment

And firebase accepted it, make sure it doesn't say unsigned on the apk file name.

Illusage answered 15/4, 2021 at 19:28 Comment(0)
G
0

Just find apk from ...\YOU_PROJECT\app\build\outputs\apk\debug

not from ...\YOU_PROJECT\app\debug

Giffer answered 7/7, 2021 at 5:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.