Since my game has 100Mb I need to use expansion file. I put below code in the MainActivity in function onCreate()
ZipResourceFile expansionFile = null;
try {
expansionFile = APKExpansionSupport.getAPKExpansionZipFile(getApplicationContext(),2,0);
} catch (IOException e) {
e.printStackTrace();
}
I don't use patch expansion file, just main, so I guess putting 0 as a version is correct. When I log to check if expansionFile was successfully loaded I get null value.
if(expansionFile == null)
Gdx.app.log("EXPANSION_FILE", "NULL");
else
Gdx.app.log("EXPANSION_FILE", "NOT NULL");
I followed instructions on https://developer.android.com/google/play/expansion-files.html and I put manually main.2.com.my.game.obb file in folder on my Nexus device:
Internal storage\Android\obb\com.my.game\
There are other obb files in Android\obb folder from other games, so this has to be a correct place. Any clues of why it doesn't mount the obb expansion file?
UPDATE
I implemented DownloaderActivity
and it downloads expansion file without any problems. It was giving me "Not a zip archive" log message. I found a way to avoid it. I zipped OBB file and uploaded it to Developer Console. It automatically converted into OBB anyway but this time when I downloaded it on my Nexus it no longer gives me null value for ZipResourceFile
and it doesn't give me "Not a zip archive" message anymore. But still I can't access files from it since I'm using AssetManager from Libgdx.
I found another way, which I'm testing now.