Search code examples
androidapk-expansion-files

Best practice to check the validity of an APK expansion obb


What's the best practice to check the validity of an APK expansion obb in case i'm using a zip file ?


Solution

  • If you are using zip as your OBB payload, you can use APK Expansion ZIP library loaded at

    /extras/google/google_market_apk_expansion/

    Which contains 3 directories:

    /downloader_library - library used to download OBB

    /zip_file - library providing helper functions to use a ZIP OBB file

    /downloader_sample - sample for using both downloader_library and zip_file

    If you check the source code in /downloader_sample you'll obtain Google sample code that does validation by doing the following (after checking that OBB file exists):

    1. Checks to see if the file size matched correct size, you have to store the correct size in your APK, something you'll need to remember to do each time you update your OBB file
    2. Computes the CRC for each file to see if they are correct

    Obvious if your OBB file is large it'll take a bit of time, so you'll want to do it just once and store the validation result for future reference.

    You can find a quite complete Android Dev article on this here.