Search code examples
androidapk-expansion-files

Expansion file downloaded but not there


So I've copied the expansion package sample for Android and made it run based on the guide provided by google. I've successfully made it work by storing a local .obb file but I can't manage to get it to work with downloading the .obb file. The state is changed to IDownloaderClient.STATE_COMPLETED but no file it to be found.

Steps I've been through:

  1. Make sample run (updated with BASE64_PUBLIC_KEY, new package name, version number)
  2. Successfully test with local .obb file.
  3. Make apk and upload to Play together with expansion file.
  4. Install signed apk and run app. <-- here it says download was a success but without giving any progress updates during the download process.

Please help getting the expansion file downloaded.

Edit: At step 4 I now get Download failed because the resouces could not be found.

Edit 2: So after debugging I see that status changes to no download required but it fails to validate file as it is missing. So for some reason it thinks the file has been downloaded.

Edit 3: So inside DownloaderService.class we have a run() method which makes a getExpansionURLCount() which returns 0. Documentation says: this will return zero if there has been no LVL fetch in the current session. After more digging I see that the response I get from Google in processServerResponse() has the response code 256 and no keys with FILE_URL. So what is the cause for this?


Solution

  • I know this answer doesn't address the underlying problem, but I thought this explanation might help others like me who have been confused by the responses from the downloader library:

    The downloader service will (somewhat un-intuitively) pass STATE_COMPLETED to onDownloadStateChanged() when the Google Licensing server informs it that there are no expansion files associated with the app. Since it has to make an async call to the server to find this out, it can't just return NO_DOWNLOAD_REQUIRED directly from startDownloadServiceIfRequired(). It has to start the service to consult the server.

    But it seems it will only do this the first time you call the download service after your app is installed - after that, it caches the response from the licensing server in a local database, and future calls to startDownloadServiceIfRequired() will immediately return NO_DOWNLOAD_REQUIRED.

    Response code 256 corresponds to Policy.LICENSED, meaning the package name and public key are valid, but the lack of any FILE_URL suggests that Google Play thinks there is no expansion file for the app.

    In my case, my expansion file worked when the app was in draft, but once published, it effectively disappeared from the store. I have not been able to determine why.