zyndor
zyndor

Reputation: 1468

Still failing to mount APK expansion file?

I have a largely native Android game on my hands which has to employ APK expansion files for the usual reasons. The project targets API level 21, and is 64-bit only.

Downloading the APK expansion works.

Mounting does not work: for an unencrypted obb, I get an error state 20 (AOBB_STATE_ERROR_INTERNAL). For an encrypted one I get a 21 (AOBB_STATE_ERROR_COULD_NOT_MOUNT).

The APK expansion is created with the jobb tool.

The versionCode is matching the one in my AndroidManifest.xml.

The key (when used), is correct.

The obb file obviously exists, and I'm getting the obb mount path by the way of

String packageName = getPackageName(); // we're in the activity
PackageManager pm = getPackageManager();
return Environment.getExternalStorageDirectory().getAbsolutePath() + 
    EXP_PATH + packageName + "/main." + 
    pm.getPackageInfo(packageName, 0).versionCode + "." + packageName +
    ".obb";`.

The result I get is the same both with an NDK implementation and with a Java implementation.

I understand that this was broken for years, but it has been fixed. Is it really? What am I doing wrong?

Upvotes: 3

Views: 512

Answers (1)

zyndor
zyndor

Reputation: 1468

After hours and hours of digging, and nearly abandoning hope all, I've found success. And it's ridiculous. But it works.

Make sure that the path you're feeding to storageManager.mountObb() (or AStorageManager_mountObb()) has any leading slashes removed. I.e.

if (obbPath != null && obbPath.startsWith('/'))
{
    obbPath = obbPath.substring(1);
}

The one that you get from Environment.getExternalStorageDirectory() will have one.

Hope this helps save someone time.

Upvotes: 1

Related Questions