Google Play 错误:无法上传仅供测试的 APK [英] Google Play error: cannot upload a test-only APK

查看:25
本文介绍了Google Play 错误:无法上传仅供测试的 APK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将第一个 apk 上传到 GooglePlay 控制台中最近创建的项目时,我收到此错误:

When trying to upload the first apk to a recently created project in GooglePlay console, I receive this error:

您不能上传仅供测试的 APK

You cannot upload a test-only APK

按照今天的情况,在 Google 中搜索该确切字符串的结果为 0.

Searching Google gives me 0 results for that exact string as per today.

我还提交了 Play 管理中心的票证.如果有任何答案,将在这里更新.

I also have submitted a ticket for Play Console. Will update here if have any answer.

2017 年 11 月 29 日更新

正如@paul-lammertsma 建议的那样,有一个解决方法.仍然很高兴知道为什么我们需要采用 gradle 方式,而我们不能通过 IDE 来实现.

As @paul-lammertsma suggested, there's a workaround. Still would be good to know why we need to go gradle way and we cannot do it via IDE.

推荐答案

通过 Android Studio 3.0 及更高版本构建应用程序会将 android:testOnly="true" 添加到应用程序清单中,标记APK 为 FLAG_TEST_ONLY对于 PackageManager.在此处了解有关 CommonsBlog 的更多信息.

Building your app through Android Studio 3.0 and later will add android:testOnly="true" to your application manifest, marking the APK as FLAG_TEST_ONLY for the PackageManager. More information on CommonsBlog here.

尝试在 Android Studio 之外安装此类 APK 会失败:

Attempting to install such an APK outside of Android Studio will fail with:

安装 app-debug.apk 失败:失败 [INSTALL_FAILED_TEST_ONLY: installPackageLI]

Failed to install app-debug.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

尝试将其上传到 Google Play 也会失败,并显示:

Attempting to upload it to Google Play will also fail, with :

您不能上传仅供测试的 APK

You cannot upload a test-only APK

对此有四种解决方案:

只需选择构建 APK(s)";来自构建"Android Studio 中的菜单.

Simply select "Build APK(s)" from the "Build" menu in Android Studio.

只需选择生成签名的 APK...";来自构建"Android Studio 中的菜单.提供密钥库并在显示的对话框中输入签名详细信息.

Simply select "Generate Signed APK..." from the "Build" menu in Android Studio. Provide the keystore and enter the signing details in the dialog that displays.

您当然可以简单地从终端执行 Gradle 以实现一些自动化,例如,如果您的部署周期通过 CI 运行(我强烈推荐!):

You can of course simply execute Gradle from the terminal for some automation, for instance if your deployment cycle runs through CI (which I highly recommend!):

./gradlew assembleRelease

(或者,您可能更喜欢在 Android Studio 的 Gradle 窗格中运行此 Gradle 任务.)

(Alternatively, you may prefer running this Gradle task from the Gradle pane from within Android Studio.)

如果您不喜欢这种行为,您可以选择将此标志添加到您的 gradle.properties.请注意,测试标志是为了保护您自己,所以您不会意外发布仅用于测试的 APK!

If you don't like this behavior, you may elect to add this flag to your gradle.properties. Beware that the test flag is for your own protection, so you don't accidentally publish a test-only APK!

# Disble testOnly mode for Android Studio
android.injected.testOnly=false

这篇关于Google Play 错误:无法上传仅供测试的 APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆