13
votes

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

8
is this a v1 or v2 signature? Is APK have debuggable true in build.gradle? - Prashant Sable
@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. - Zohaib Akram
Debuggable flag should be false and not true while uploading the APK. - Prashant Sable
@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? - Zohaib Akram
You should not use debug keystore to upload the apk. Create new release key store and use to sign the APK - Prashant Sable

8 Answers

11
votes

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

8
votes

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.

7
votes

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

2
votes

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

1
votes

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.

0
votes

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.

0
votes

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.

0
votes

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

not from ...\YOU_PROJECT\app\debug