Zohaib Akram
Zohaib Akram

Reputation: 627

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

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

Upvotes: 20

Views: 4552

Answers (8)

close_file
close_file

Reputation: 331

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

not from ...\YOU_PROJECT\app\debug

Upvotes: 0

rt_
rt_

Reputation: 1195

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.

Upvotes: 1

Dishant Dishu
Dishant Dishu

Reputation: 81

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.

Upvotes: 1

getKonstantin
getKonstantin

Reputation: 1250

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)
        }
    }
}

Upvotes: 3

倚楼听风雨
倚楼听风雨

Reputation: 11

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.

Upvotes: 1

Andrew
Andrew

Reputation: 2886

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.

Upvotes: 11

v0rin
v0rin

Reputation: 500

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 :).

Upvotes: 15

Prashant Sable
Prashant Sable

Reputation: 1013

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

Upvotes: 7

Related Questions