Some information for the people who get here in this post, as there are some things that have changed in how the apk extensions work, and also if you use Android Studio to work libraries.
NOTE 1
You can no longer use the draft because the link to the extension file is not yet activated. You must first download the version in Alpha or Beta with the extension file. (adding the extension file is possible only from the second apk file you upload). Therefore, make sure that you see the apk extension file specified when you click details in the developer publishing section of the APK.
NOTE 2
If you are using android studio and want to use the loader library, do not just copy the package name and java files into your own src application directory. Import the bootloader library into eclipse and select export => gradle build files. Subsequently, you can import the library as a module in the Android studio.
NOTE 3
Not sure about this, but I also find it necessary to download the application at least once through the play store and access it with an account on your test device. Therefore, if you work with alpha, create a google + test group and add yourself or other test devices to it.
BTW
With these libraries, it is pretty easy to implement apk download for extension, just make sure:
your activity (the one where you want to implement the extension package download when the download was not done automatically) implements IDownloaderClient.
You have configured the service and receiver and configured them in your manifest.
BASE64_PUBLIC_KEY in the service class is correct. Download first apk => look in services and APIs in the developer console under your application => License code for this application.
This code is used to see if the extension file can be found on the device:
boolean expansionFilesDelivered() { for (XAPKFile xf : xAPKS) { String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion); Log.i(TAG, "Expansion filename " +fileName); if (!Helpers.doesFileExist(this, fileName, xf.mFileSize, false)) return false; } return true; }
It uses the XAPKS class, which represents an extension file, whether it is a main file or a patch file having a specific file size (bytes) and associated with the apk version (the one to which it was first added).
private static class XAPKFile { public final boolean mIsMain;
It is also quite easy to read movie files and other materials directly from the extension file using the zip tools provided by google (com.android.vending.zipfile).
First, get the extension file using the methods provided in the library, the parameters are integers that represent your main version of the extension apk (the version of apk in which you need to add the extension package) and the version of apk patch.
ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(context, APKX_MAIN_APK, APKX_PATCH_APK);
Video
To play videos directly from this zipresourcefile:
AssetFileDescriptor a = expansionFile.getAssetFileDescriptor(pathToFileInsideZip);
Now from this FileDescriptor property you can get a FileDescriptor and use it in your media player, the correct syntax for getting a media player for video playback also requires the second and third parameters. Be it the entry level and length that you can get from the AssetFileDescriptor.
player.setDataSource(a.getFileDescriptor(), a.getStartOffset(), a.getLength());
Other
For all other things (like images) you can just get the zipresourcefile input file:
expansionFile.getInputStream(pathToFileInsideZip);`
Also, make sure you don't compress the video in zip for this to work! For example, do not compress .mp4 files:
zip -n .mp4 -r zipfile.zip . -x ".*" -x "*/.*"