2

我尝试使用 Firebase 测试实验室测试应用,但收到错误消息“不允许使用 testOnly APK”。

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>

但是,当我通过将部署目标选项设置为“Firebase 测试实验室设备矩阵”在 Android Studio 3.0 RC1 中运行它时,firebase 测试有效。

我在我的项目中搜索了“testOnly”,但没有找到。看起来它是 gradle 将属性注入到 AndroidManifest.xml 中。

有谁知道如何解决它?

4

3 回答 3

3

我有同样的问题。我终于通过使用“Build > Build APK(s)”生成 apk 来解决

APk 生成于:app\build\outputs\apk\debug

该 apk 是使用“testOnly”标签生成的,它在 firebase 上运行。我在https://developer.android.com/studio/run/index.html上找到了这个信息

于 2017-11-28T01:53:17.393 回答
1

是 Android Studio 添加了该字段。参考文档developer.android.com/guide/topics/manifest/...“Android Studio点击运行时自动添加该属性”。不使用 Android Studio,我从命令行构建了一个 APK,然后我可以将它上传到 Firebase 测试实验室进行测试。

于 2017-10-23T03:28:02.717 回答
0

当您使用即时运行选项时,以这种方式生成的 APK 不能用于任何类型的 firebase 测试。

而是选择上面的构建选项,然后选择构建 APK 选项,以这种方式生成的 APK 可用于 firebase 测试。

于 2018-01-22T12:59:40.350 回答