Question

[UPDATE]

I uninstalled and then installed again the application on the test device, and it started working fine.


I'm implementing APK Expansion file support (but no XAPK ZIP library support).

The documentation implies that if a required APK Expansion file is missing (e.g. it got deleted from the obb folder), my application will re-download it. This doesn't happen for me; my app keeps saying NO_DOWNLOAD_REQUIRED. It seems that the Google Play Downloader Library gets null for the download info from its SQLite database. Note that I haven't updated the draft APK and Expansion file on Google Play - they are still the first version. Moreover, the versionCode of the APK uploaded to Google Play is also identical with the one on the test device.

In details:

  1. There was an APK Expansion file in the correct folder (obb). I used it for testing purposes before I actually started implementing the downloader functionality.
  2. When the Downloader implementation (based on Google Play Downloader Library) was finished, I changed the size of the above obb file to make it invalid for my app. Therefore, this makes my app call the startDownloadIfNeeded() method.
  3. First, I ran my implementation without any files on Google Play. The response was, as I expected: "Download failed because the resources could not be found"
  4. Then I uploaded my 40MB APK and a 4 MB expansion file to Google Play (for testing purposes). Note that this 4 MB expansion file is not the invalid one which was left in the obb folder. When I ran my implementation, the response came after 1.5 seconds: "Download complete".
  5. This was strange, because my internet connection is not so fast to download 4 MB. Indeed, the obb folder (the folder for APK Expansion files) still contained the invalid expansion file that I initially put there manually. That is, nothing was downloaded!
  6. I deleted the invalid file, i.e. the obb folder is now empty, but still no download starts, and Downloader Library says NO_DOWNLOAD_REQUIRED. (I checked its internal implementation: when it queries an SQLite database for download info, it gets null after the query.)

I just read on SO somewhere that the APK Expansion files uploaded to Google Play require a few hours to take effect. In my case, I tested my implementation immediately after upload. But it must have noticed that there are files on Google Play, because instead of "resources could not be found", it gave a different message ("Download completed"). Too bad that it didn't actually download anything; and since then, it doesn't even try to (it keeps returning NO_DOWNLOAD_REQUIRED).

What am I missing?

Shouldn't the Downloader Library notice if an APK Expansion file gets deleted? Its implementation seems to deal with this, but only if the SQLite database query returns non-null for downloadable files.

The relevant part of internal implementation of Google Play Downloader Library (the last comment is mine):

    int status = NO_DOWNLOAD_REQUIRED;

    // the database automatically reads the metadata for version code
    // and download status when the instance is created
    DownloadsDB db = DownloadsDB.getDB(context);

    // we need to update the LVL check and get a successful status to
    // proceed
    if (isLVLCheckRequired(db, pi)) {
        status = LVL_CHECK_REQUIRED;
    }
    // we don't have to update LVL. do we still have a download to start?
    if (db.mStatus == 0) {
        DownloadInfo[] infos = db.getDownloads();
        if (null != infos) {
            for (DownloadInfo info : infos) {
                if (!Helpers.doesFileExist(context, info.mFileName, info.mTotalBytes, true)) {
                    status = DOWNLOAD_REQUIRED;
                    db.updateStatus(-1);
                    break;
                }
            }
        }            
        /// <----- This is when infos==null, in this case result will be NO_DOWNLOAD_REQUIRED

    } else {
        status = DOWNLOAD_REQUIRED;
    }
Was it helpful?

Solution

If you encounter the same issue, uninstall the application, and then install it again. (Don't let Eclipse reinstall it in the usual way. Uninstall it completely from the device, manually.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top