Search code examples
pythonandroidgoogle-apigoogle-play-console

Application bundles uploaded using Google Developer API do not appear anywhere, despite successful request execution


Here is the Python code I am using, building on the googleapiclient module:

from googleapiclient.discovery import build, MediaFileUpload
from oauth2client.service_account import ServiceAccountCredentials

app_id = "com.myapp.myapp.app"
aab_file_path = "H:/packages/0.0.18/com.myapp.myapp.app.aab"
service_account_file_path = "service-account-key.json"

# Create the service account credentials object.
credentials = ServiceAccountCredentials.from_json_keyfile_name(
    service_account_file_path, ["https://www.googleapis.com/auth/androidpublisher"]
)

# Create the API client object.
service = build("androidpublisher", "v3", credentials=credentials)

# Get an edit ID.
request = service.edits().insert(packageName=app_id)
response = request.execute()
editId = response['id']

media_body = MediaFileUpload(aab_file_path, mimetype='application/octet-stream', resumable=True)
request = service.edits().bundles().upload(
    packageName=app_id,
    editId=editId,
    media_body=media_body,
)
response = request.execute()

# Check that the response contains a versionCode.
versionCode = response.get("versionCode")
if response.get("versionCode") is not None:
  print("Bundle successfully uploaded.")
else:
  print("Failed to upload bundle.")

The script runs through, the versionCode retrieved is correct, but the bundle is not actually visible in the App bundle explorer in the Google Play Console, neither is it useable to update a track, or returned by edits.bundles.list.

Could someone please explain to me what I am doing wrong?


Solution

  • With some help from the Play Console Help platform, I solved this. It turns out I was not committing the bundle edit like this:

      request = service.edits().commit(editId=editId, packageName=app_id)
      response = request.execute()
    

    Somehow I was convinced that I had tried that and it was telling me the edit was already committed, but I must have dreamt it.