I am trying to create an expansion pack for an Android app which includes about 100 .mp3 files. As I understand from the documentation and this SO question, the zip file must be 0% compressed.
How do I create a 0% compressed zip file on a mac?
I am trying to create an expansion pack for an Android app which includes about 100 .mp3 files. As I understand from the documentation and this SO question, the zip file must be 0% compressed.
How do I create a 0% compressed zip file on a mac?
The following is a working implementation of the expansion pack with a zip file containing .mp3 files:
Create a zip file with 0% compression (on a mac in terminal):
Put all of the files you want to compress in a folder. Let's call it FOLDER_WITH_FILES_TO_ZIP
cd into the parent directory of FOLDER_WITH_FILES_TO_ZIP
Use the following bash script to create a zip file with file name FILENAME.zip
$ zip -0 -r FILENAME.zip FOLDER_WITH_FILES_TO_ZIP
Upload the a new apk along with the zip file in the google play console.
The following is example code to set the dataSource of a MediaPlayer object from the zip file. Notice how I include FOLDER_WITH_FILES_TO_ZIP/
as part of the path to the .mp3 file. That's crucial.
soundFileName = "test_file.mp3";
soundFileName = "FOLDER_WITH_FILES_TO_ZIP/" +soundFileName;
try{
// Get a ZipResourceFile representing a specific expansion file
ZipResourceFile expansionFile = APKExpansionSupport.
//Get the zip file with main obb file version 7 and no patch obb file
getAPKExpansionZipFile(MainActivity.this.getApplicationContext(),7,0);
//Get the asset file descriptor
AssetFileDescriptor assetFileDescriptor = expansionFile.getAssetFileDescriptor(soundFileName);
//Set the dataSource
mediaPlayer.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength());
}
catch (IllegalArgumentException e) { e.printStackTrace(); }
catch (IllegalStateException e) { e.printStackTrace();}
catch (IOException e) {e.printStackTrace(); }
Try to create expansion file using this command
$ jobb -d pathToFolder -o fileName.obb -k secret-key -pn packageName -pv 1
For more details see This