3

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?

zyndor
  • 1,418
  • 3
  • 20
  • 36

1 Answers1

1

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.

zyndor
  • 1,418
  • 3
  • 20
  • 36
  • I wish it fixed my problem :( Thanks for taking the time at least :) The android obb handling is a big joke, especially from NDK – Viktor Sehr Oct 03 '17 at 18:37
  • @ViktorSehr Agreed. Unfortunately a full-native activity has proven unviable at least for the project that I've been working on. As soon as you have to touch Android UI or integration with Google's APIs (for which there also exists an NDK wrapper, I understand), ANativeActivity out goes the window. Sorry for the answer not being helpful; please feel free to post a question and if you link it here, I'll endeavour to help. – zyndor Oct 03 '17 at 18:53
  • 1
    Yes, I think it's somewhat a shame that google doesn't hire a few people to just to make a nice, clean C++ (or at least C) API. (If you're reading this google, I'm up for hire :) – Viktor Sehr Oct 22 '17 at 21:27