如何使用 Google Play Developer API Java 客户端库将扩展文件上传到 Draft Apk?

How do you upload an expansion file to a Draft Apk using Google Play Developer API Client Library for Java?

我目前的工作流程是将我的 apk(按 abi 拆分 4 个)发布到草稿中的 alpha。这很好用,因为我使用的是 Gradle Play Publisher。

下一步是我上传扩展文件,这是一个自定义 gradle 任务。

我使用经过身份验证的 AndroidPublisher 开始编辑

val editId=publisher.edits().insert(packageName, null).execute().id

对于我的第一个 apkVariant,我上传了扩展文件

publisher.edits().expansionfiles()
                .upload(
                  packageName,
                  editId,
                  apkVariantOutput.versionCodeOverride,
                  "main",
                  FileContent("application/octet-stream",myFile)
                ).execute()

对于所有后续变体,我参考了新的扩展文件

publisher.edits().expansionfiles().update(
            packageName,
            editId,
            apkVariantOutput.versionCodeOverride,
            "main",
            ExpansionFile().apply {
              referencesVersion = apkVariants[0].versionCodeOverride
            }
          ).execute()

最后提交此编辑

publisher.edits().commit(packageName, editId).execute()

一些印刷品的示例输出:

{
  "expiryTimeSeconds" : "1573666146",
  "id" : "04893130212727174754"
}
setting expansion for 6193171
{
  "fileSize" : "590199"
}
{
  "referencesVersion" : 6193171
}
{
  "referencesVersion" : 6193171
}
{
  "referencesVersion" : 6193171
}
{
  "expiryTimeSeconds" : "1573666146",
  "id" : "04893130212727174754"
}

但是扩展文件永远不会出现在 Play 控制台上,即使任务完成时没有错误。

我希望我从根本上误解了这件事 API 因为我无法理解这一点。

我用 Play Developer API 重写了整个应用程序上传过程。

您无法将扩展文件上传到草稿,this question 仍然相关。我找不到它提到的 google 问题,但一年后显然仍然如此。