I would like a way to access my expansion file in Cordova.
The issue is that the plugin I've heard most people recommend;
https://github.com/agamemnus/cordova-plugin-xapkreader
requires a bit more effort to get it working, namely modifying boilerplate Cordova files. I don't get to see or access these files with PhoneGap Build as it generates and compiles these files, along with my www files, into an apk in one go.
Is there a way to get this plugin working with PhoneGap Build, and if not, is there an alternative that I could perhaps use?
I eventually figured it out. I'll leave the answer here for anyone that may have a the same problem I did.
So this plugin: https://github.com/agamemnus/cordova-plugin-xapkreader
Works just fine with Phonegap Build. The issue was actually with the methods I was trying to use in setting it up correctly. The correct steps to take are as follows:
In your root/config.xml file, add the following:
<plugin name="com.flyingsoftgames.xapkeader" spec="https://github.com/agamemnus/cordova-plugin-xapkreader.git#cordova-6.5.0">
<variable name="XAPK_EXPANSION_AUTHORITY" value="YOUR_APP_NAME" />
<variable name="XAPK_PUBLIC_KEY" value="YOUR_GOOGLE_KEY"/>
</plugin>
Wherever you want a file to access the apk expansion file, use the following syntax:
content://YOUR_APP_NAME/path/to/file.jpg
This is fairly clear about it in the documentation, but it's worth noting that you set the path correctly. A lot of tutorials online will have you write something like:
content://YOUR_APP_NAME/main_expansion/path/to/file.jpg
This made me believe that the main_expansion portion of the path was a syntax meant for the plugin to access the main expansion file and not the patch expansion file, but this is resolved by the plugin as it prefers files in the patch to the main automatically.
The main_expansion portion is there because that's the file path that the tutorials online created. So their actual file path would be
main_expansion/images/funny_image.jpg
whereas mine was something like
audio_files/dialog/hello.mp3
It sounds so simple but this caused me an unnecessary amount of trouble.
Also, it's worth noting that it didn't work when I was using Cordova cli 6.2.0, but worked when I upgraded to 6.5.0. This is done in your root/config.xml file:
<preference name="phonegap-version" value="cli-6.5.0" />