Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Expansion file downloads via Google licensing plugin — Gideros Forum

Expansion file downloads via Google licensing plugin

PaulHPaulH Member
edited May 2014 in Plugins
I'm stumped by the non-action of the expansion file download function of the Google licensing plugin. After calling checkExpansion() the event listener for Event.DOWNLOAD_REQUIRED is triggered, which seems to correctly recognize that the Google has an expansion file for the app with the given key, and that it is not present on the device. My understanding was that the download would begin in that case, and I assumed there would be events handled by the DOWNLOAD_STATE and DOWNLOAD_PROGRESS listener. None of those event listeners are being triggered, and I see no events at all after DOWNLOAD_REQUIRED.

I'm testing on an Android device, with a Gideros player app built with the in-app billing and Google licensing plug ins, and that app is in debug mode in Eclipse. The LogCat shows nothing from the time the player is up and running. I'm not seeing anything showing up in sdcard/Android/obb where I would expect the expansion file to be downloaded on the device.

Anyone have any ideas what I'm missing?

PaulH

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Hello @PaulH ;)
    Yes the plugin should also manage downloading of the expansion files with the events you stated.
    Why it does not work for you, can be multiple reasons.

    Firstly are you connected to Internet.
    If yes, are you connected through WiFi? Because by default it won't download through cellular networks.

    Also with release version you sign the apk with your certificate, and I think licensing and probably also expansion was somehow bind to certificate, so it is possible that it won't run as expected on debug version through eclipse.

    I think @zoolax (from this thread: http://giderosmobile.com/forum/discussion/comment/36040#Comment_36040) was the last one playing with expansion files, maybe he knows something more on that
  • PaulHPaulH Member
    Thanks for the reply. I'm really frustrated right now and grasping at straws. I thought I may have complicated things by trying to troubleshoot both IAB and expansion at the same time, so I've started with a clean exported Android project and added only the licensing plugin.

    Yes, the device is connected via WiFi (it's a wifi only tablet.) I've also tried enabling cellular downloads in the app just in case there was a bug in code related to when downloads would be allowed.

    The behavior I'm seeing is the same in a signed app as in Eclipse. I've uploaded the app to the store as an Alpha test, with code in place to show updates in response to any of the licensing and expansion related events. It shows the first event, that Google replied that an expansion file needs to be downloaded, and no other events.

    I've just reinstalled the app on the tablet via the Play Store directly, and on this device the store actually did the download automatically. I see the expansion file on the SD card where it should be. Yet the app still gets the one response from the server, saying a download is needed. It's as though communication from the server is not really happening, but if I add a character to the app's public key I get the invalid key response from the server.

    Any other possibilities that come to mind?

    PaulH
  • PaulHPaulH Member
    Further stumped. My app is no failing to read files from the expansion file even if I create it and install it manually. I suspected it was having trouble reading the SD card while connected to the PC via USB. Unplugged, rebooted device, same thing.

    Stranger still, if I disable Wifi on the device and restart the app, it's still getting the DOWNLOAD_REQUIRED event. Clearly the server wasn't really consulted. Perhaps it's just deciding the download is required as there is no OBB folder. Trying to step through the plugin code in Eclipse...

    Paul
  • PaulHPaulH Member
    edited May 2014
    Found the problem. The installation instructions for the plugin include this (XML tag markers removed to play nice with the forum):

    Add service android:name=".GiderosAPKDownloader" in application tag
    Add receiver android:name=".GiderosDownloadReceiver" in application tag

    But if you just copy in the src folder as per the instructions it really needs to be added like this:

    service android:name="com.giderosmobile.android.plugins.googlelicensing.GiderosAPKDownloader"
    receiver android:name="com.giderosmobile.android.plugins.googlelicensing.GiderosDownloadReceiver"

    The other option would be to move those files to the top of the src folder.

    Installed as described the service never starts, no no more events are triggered. Now the download actually happens, though the download_complete event doesn't seem to be happening. Oh well - I'm just happy to be making progress again!

    PaulH

  • ar2rsawseenar2rsawseen Maintainer
    @PaulH sorry for delayed replies, am currently on vacation.

    Yes you are right about the package names, updated the example manifest in the labs and install instructions

    About the events then download state should have changed.

    Download state should have this possible values:
    switch (newState) {
                case IDownloaderClient.STATE_IDLE:
                	onDownloadState("STATE_IDLE", "Waiting for download to start", sData);
                case IDownloaderClient.STATE_FETCHING_URL:
                	onDownloadState("STATE_FETCHING_URL", "Looking for resources to download", sData);
                case IDownloaderClient.STATE_CONNECTING:
                	onDownloadState("STATE_CONNECTING", "Connecting to the download server", sData);
                case IDownloaderClient.STATE_DOWNLOADING:
                	onDownloadState("STATE_DOWNLOADING", "Downloading resources", sData);
                case IDownloaderClient.STATE_COMPLETED:
                	onDownloadState("STATE_COMPLETED", "Download finished", sData);
                case IDownloaderClient.STATE_PAUSED_NETWORK_UNAVAILABLE:
                	onDownloadState("STATE_PAUSED_NETWORK_UNAVAILABLE", "Download paused because no network is available", sData);
                case IDownloaderClient.STATE_PAUSED_BY_REQUEST:
                	onDownloadState("STATE_PAUSED_BY_REQUEST", "Download paused", sData);
                case IDownloaderClient.STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION:
                	onDownloadState("STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION", "Download paused because wifi is disabled", sData);
                case IDownloaderClient.STATE_PAUSED_NEED_CELLULAR_PERMISSION:
                	onDownloadState("STATE_PAUSED_NEED_CELLULAR_PERMISSION", "Download paused because wifi is unavailable", sData);
                case IDownloaderClient.STATE_PAUSED_WIFI_DISABLED:
                	onDownloadState("STATE_PAUSED_WIFI_DISABLED", "Download paused because wifi is disabled", sData);
                case IDownloaderClient.STATE_PAUSED_NEED_WIFI:
                	onDownloadState("STATE_PAUSED_NEED_WIFI", "Download paused because wifi is unavailable", sData);
                case IDownloaderClient.STATE_PAUSED_ROAMING:
                	onDownloadState("STATE_PAUSED_ROAMING", "Download paused because you are roaming", sData);
                case IDownloaderClient.STATE_PAUSED_NETWORK_SETUP_FAILURE:
                	onDownloadState("STATE_PAUSED_NETWORK_SETUP_FAILURE", "Download paused. Test a website in browser", sData);
                case IDownloaderClient.STATE_PAUSED_SDCARD_UNAVAILABLE:
                	onDownloadState("STATE_PAUSED_SDCARD_UNAVAILABLE", "Download paused because the external storage is unavailable", sData);
                case IDownloaderClient.STATE_FAILED_UNLICENSED:
                	onDownloadState("STATE_FAILED_UNLICENSED", "Download failed because you may not have purchased this app", sData);
                case IDownloaderClient.STATE_FAILED_FETCHING_URL:
                	onDownloadState("STATE_FAILED_FETCHING_URL", "Download failed because the resources could not be found", sData);
                case IDownloaderClient.STATE_FAILED_SDCARD_FULL:
                	onDownloadState("STATE_FAILED_SDCARD_FULL", "Download failed because the external storage is full", sData);
                case IDownloaderClient.STATE_FAILED_CANCELED:
                	onDownloadState("STATE_FAILED_CANCELED", "Download cancelled", sData);
                default:
                	onDownloadState("STATE_UNKNOWN", "Unknown state", sData);
            }
    Additionally try listening to Event.ERROR if you are not doing it already, which may shed a light on if something is not working
  • PaulHPaulH Member
    Thanks for the response while on vacation! I'm listening for the error too, and not seeing any.

    The download is completing, and my app is getting the STATE_COMPLETED event after all, but strangely that's followed by the states for paused due to network unavailable, paused by request, wifi disabled, need cellular permission, need wifi, roaming, network setup failure, sd card unavailable, unlicensed, fetching URL, sd card full, canceled, and finally settles on state_unknown. It seems this whole list of events fire after the download is completed for some reason, but my code can ignore any state changes once the download is complete.

    By the way this all works fine using the custom player on the device and running through the Gideros Studio.

    So the download issue is resolved, but now my code doesn't seem to be able to access the contents in the expansion file. Am I correct in understanding that an io.open(file_path, "r") should open the file if it finds it as a resource in the APK itself, or failing that, in the patch expansion file, or failing that, in the main expansion file? So any file opened with the resource path marker ("|R|") or none since that's the default, should work that way?

    Paul
  • ar2rsawseenar2rsawseen Maintainer
    @PaulH that's might be a bug in code, will check when I get home.
    But as far as I remember, you don't need to access the downloaded files in any way, thats all done internally, you just simply do the same, as you would do on desktop or in Gideros player
    Texture.new("images/myimage.png") --etc
  • PaulHPaulH Member
    That's what I thought. I'd swear I had that working before I started dealing with the download issue. Could an error in my installation of the licensing plugin have anything to do with it, or is the code that accesses the expansion file in Gideros itself?

    Paul
  • PaulHPaulH Member
    Ah. Here's what's going on. I've been trying to access a text file in the expansion file, to test the system, and that's not working. In the exported assets the file is renamed with a ".jet" extension added, but I can't open it whether I add the extension to the path I'm trying to open or not. But I can open image files just fine. It seems there may be a bug in dealing with those file types that get renamed during the Android export.

    That gives me a workaround. Rather than moving the folders that contain the bulk of the images and some supporting text and dat files into the expansion file, I can keep the folders, text and dat files in the APK and just pull the images out to the expansion file.

    Thanks again for taking time to respond. Enjoy the rest of your vacation!

    Paul
  • PaulHPaulH Member
    I was mistaken about having a workaround - the code can't open the image files after all. The images I tested were still part of the APK, so I still can't seem to access any files from the expansion file. Still experimenting...
  • ar2rsawseenar2rsawseen Maintainer
    edited May 2014
    @PaulH you can't have same files in expansion and apk if that is the problem

    also about .jet, it is already changed in exported project so should be working correctly.

    Basically how you should create the expansion files is by zipping with store some large files or folders and deleting them from assets folder, more info here:

    http://giderosmobile.com/DevCenter/index.php/APK_Expansion_Files

    So at first please try testing as described in the link and if that works try uploading it to Google Play and doing download.
  • PaulHPaulH Member
    Those are the directions I've followed to create the expansion file. It's an uncompressed zip file (made via 7za a -mx0) containing 4 folders at it's root, which are 4 folders that were moved from the exported projects assets/assets folder. Those folders contain many subfolders that contain most of the images the app users. I've tried manually renaming and installing the expansion file, letting the Play Store install it, and now letting the Google Licensing library install it. I'll try building the zip file with another tool and see if that makes a difference.

  • PaulHPaulH Member
    Anyone have any thoughts? I'm still stuck on reading from the expansion files. I've built a new minimalist project, hopefully the "hello world" of accessing an expansion file. The project containing just a font, one lua file and a text file called test.txt. The lua file contains:

    file, result = io.open("test.txt", "r")
    local nehe = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
    message_font = TTFont.new("interstate black.ttf",42, nehe)
    if (file ~= nil) then
    text = string.format("Opened.")
    else
    text = string.format("Not opened: %s", result)
    end
    local tf = TextField.new(message_font, text)
    tf:setPosition(600,10)
    stage:addChild(tf)
    tf:setRotation(90)

    If I run on the Windows player, or export an Android project and run via Eclipse on an Android device, it says "opened", meaning it was able to open the text file. That's using the text file from within the APK.

    To move the text file to an expansion file, I remove the text file (renamed test.txt.jet during the Gideros export) from (exported project)/assets/assets, and put it in an uncompressed zip file using:

    7za a -mx0 main.1.com.mydomain.myapp.obb test.txt.jet

    I manually copy that file to (sdcard)/Android/obb/com.mydomain.myapp.

    I rebuild the app via Eclipse to get the APK without the text file, and run on the device. It displays "Not opened: No such file or directory". At this point I expected to see the "Opened" message indicating the text file was found in the expansion file.

    I get the same effect if I use WinRar to build the uncompressed zip file rather than 7Zip, using "store" as the method and zip as the file type, the renaming the zip file to the obb file name. It seems unlikely the problem is the way the expansion file is built, and I've repeatedly checked that the naming of the package of the APK matches the name of the folder and the package name portion of the obb file.

    I've also tried adding the Google Licensing plugin in case some of the code for reading from expansion files is in the plugin with the code that supports downloading expansion files.

    What could I be missing?

    I've put this Gideros project, the exported Android project with the text file removed, and the expansion file here: http://www.pishtech.com/expansion_file_test.zip

    Any further help would be greatly appreciated! This is pretty much the only roadblock preventing the release of my new product.

    Paul
Sign In or Register to comment.