Failed to start an instrument test from Firebase g

2019-07-23 23:09发布

问题:

I tried to test an app with Firebase Test lab but get an error saying "testOnly APKs are not allowed."

C:\temp>gcloud firebase test android run     --type instrumentation  --app myapp.apk      --test myapp-androidTest.apk    --device model=Nexus10,version=22,locale=en,orientation=landscape       --timeout 300s

Have questions, feedback, or issues? Get support by visiting:
  https://firebase.google.com/support/

Uploading [myapp.apk] to Firebase Test Lab...
Uploading [myapp-androidTest.apk] to Firebase Test Lab...
Raw results will be stored in your GCS bucket at [https://console.developers.google.com/storage/browser/test-lab-j9zwyqscmy0rw-k53tazzivjxvu/2017-10-16_11:56:43.691000_AcnJ/]

Test [matrix-1vxb29yr0b2z7] has been created in the Google Cloud.
Firebase Test Lab will execute your instrumentation test on 1 device(s).
Creating individual test executions...failed.
ERROR: (gcloud.firebase.test.android.run)
Matrix [matrix-1vxb29yr0b2z7] failed during validation: "testOnly" found in the Manifest. testOnly APKs are not allowed.

C:\temp>

But the firebase test works when I run it in Android Studio 3.0 RC1 by setting the deployment target options to "Firebase Test Lab Device Matrix".

I searched "testOnly" in my project but not found it. It looks like it was gradle injected the attribute into AndroidManifest.xml.

Does anyone know how to resolve it?

回答1:

I have the same probllem. I finally resolved by generating the apk with 'Build > Build APK(s)'

The APk is generated at : app\build\outputs\apk\debug

The apk is generated witouth the 'testOnly' label and it runs on firebase. I found this info on https://developer.android.com/studio/run/index.html



回答2:

It was Android Studio added the field. Refer to the document developer.android.com/guide/topics/manifest/… "Android Studio automatically adds this attribute when you click Run". Not using Android Studio, I built an APK from the command line then I can upload it to Firebase Test Lab for testing.



回答3:

When you use the instant run option and the APK generated in this fashion cannot be used for any kind of firebase test.

Instead select the build option above and then select the build APK option and the the APK generated in this fashion can be used for the firebase test.