Android: "Could not access APK expansion support library"

Hello,

I am trying to implement obb files into the basic android project on LazyFoo’s HelloMobile.

I created the obb file using jobb like this:
~/projects/android/android-sdk-linux/tools/jobb -pn com.tutorial.game -pv 1 -d ./world -o main.1.com.tutorial.game.obb
(where world is a directory containing 1 file: world.bin)

I push the obb onto my tablet (nvidia shield) like this:
adb push ./main.1.com.tutorial.game.obb /storage/emulated/0/Android/obb/com.tutorial.game/main.1.com.tutorial.game.obb

The androidmanifest.xml contains:
package="com.tutorial.game"
android:versionCode=“1”

the main.cpp contains:
SDL_SetHint(SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION, “1”);
SDL_SetHint(SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION, “1”);

I try to read a file like this:
string filename(“world.bin”);
SDL_RWops *fin = SDL_RWFromFile(filename.c_str(), “rb”);
if (fin != NULL)
{
cout << string("ANDROID: file ok: ") + filename << endl;
SDL_RWclose(fin);
}
else
{
cout << string("ANDROID: file NOKNOK: ") + filename << endl;
cout << string("readAndroid - SDL error: ") + SDL_GetError() << endl;
}

I have installed the following extras with the android SDKManager:
“Google Play APK Expansion library”
“Google Play Licensing library”
(both libraries are checked in the SDKManager)

Im targetting Android 4.4.2 (API 19)

I am getting following exception (in SDLActivity.java):
throw new IOException(“Could not access APK expansion support library”, ex);

Any tips would be welcome since I am struggling with this problem for over a week now.

Karel.

Hi,

installing the libraries via SDK manager is not enough. You need to make
sure they’re actually bundled with your app.

I don’t remember exactly, and it also depends on which build system you use,
but if you use “ant”, then all Java libraries that you want to include must
be in the “lib/” or “libs/” folder relative to your project’s root. With
gradle/Android Studio I don’t remember. Sorry for the fuzzy information, I
hope you can still make sth out of it.

Regards,

Daniel

---------- Původní e-mail ----------
Od: Carlos El Fietro noreply@discourse.libsdl.org
Komu: hardcoredaniel@seznam.cz
Předmět: [SDL] Android: “Could not access APK expansion support library”
"

 carloselfietro(https://discourse.libsdl.org/u/carloselfietro) 

August 29

Hello,

I am trying to implement obb files into the basic android project on LazyFoo
’s HelloMobile.

I created the obb file using jobb like this:
~/projects/android/android-sdk-linux/tools/jobb -pn com.tutorial.game -pv 1
-d ./world -o main.1.com.tutorial.game.obb
(where world is a directory containing 1 file: world.bin)

I push the obb onto my tablet (nvidia shield) like this:
adb push ./main.1.com.tutorial.game.obb /storage/emulated/0/Android/obb/com.
tutorial.game/main.1.com.tutorial.game.obb

The androidmanifest.xml contains:
package="com.tutorial.game"
android:versionCode=“1”

the main.cpp contains:
SDL_SetHint(SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION, “1”);
SDL_SetHint(SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION, “1”);

I try to read a file like this:
string filename(“world.bin”);
SDL_RWops *fin = SDL_RWFromFile(filename.c_str(), “rb”);
if (fin != NULL)
{
cout << string("ANDROID: file ok: ") + filename << endl;
SDL_RWclose(fin);
}
else
{
cout << string("ANDROID: file NOKNOK: ") + filename << endl;
cout << string("readAndroid - SDL error: ") + SDL_GetError() << endl;
}

I have installed the following extras with the android SDKManager:
“Google Play APK Expansion library”
“Google Play Licensing library”
(both libraries are checked in the SDKManager)

Im targetting Android 4.4.2 (API 19)

I am getting following exception (in SDLActivity.java):
throw new IOException(“Could not access APK expansion support library”, ex);

Any tips would be welcome since I am struggling with this problem for over a
week now.

Karel.

Thanks very much for your tip, now I was able to succesfully use my obb file.
This is what I have done:

  1. add the sources of zipfile library to my project.
    (thanks to the stackoverflow community post https://stackoverflow.com/questions/18525408/how-to-add-android-libraries-with-resources-without-using-eclipse)
  • Create a copy of the folder android-sdk-linux/extras/google/market_apk_expansion/zip_file into my project folder:
    cd my_project
    cp -r android-sdk-linux/extras/google/market_apk_expansion/zip_file zip_file

  • Generate a build.xml file for the library
    android update lib-project --path ./zip_file --target 1

  • Reference the library project and create the dependency in the project’s project.properties file
    android.library.reference.1=/zip_file

  • Build the main project
    ant clean debug
    This will automatically build the support library, too. You generally need a clean build after adding a library or changing the target versions, so the build picks up all the changes.

  1. By going through the java sources I found that if you dont use a patch file (only a main file) you can set the patch hint to "0"
    SDL_SetHint(SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION, “0”);

  2. Don’t use JOBB to create the obb. Simply zip it and rename it to with a .obb extension
    zip -r main.1.com.tutorial.game.zip ./world
    mv main.1.com.tutorial.game.zip main.1.com.tutorial.game.obb
    adb push ./main.1.com.tutorial.game.obb /storage/emulated/0/Android/obb/com.tutorial.game/main.1.com.tutorial.game.obb

Karel.

Yes, adding a library project will also work, did not think about this, I
was assuming you had a compiled library and not source code.

jobb is for creating “mountable obb images (fat32)”, but if your .obb is
just a zip file, your approach is correct.

Regards,

Daniel

---------- Původní e-mail ----------
Od: Carlos El Fietro noreply@discourse.libsdl.org
Komu: hardcoredaniel@seznam.cz
Předmět: Re: [SDL] Android: “Could not access APK expansion support library”

"

 carloselfietro(https://discourse.libsdl.org/u/carloselfietro) 

August 30

Thanks very much for your tip, now I was able to succesfully use my obb
file.
This is what I have done:

  1. add the sources of zipfile library to my project.
    (thanks to the stackoverflow community post https://stackoverflow.com/
    questions/18525408/how-to-add-android-libraries-with-resources-without-
    using-eclipse
    (https://stackoverflow.com/questions/18525408/how-to-add-android-libraries-with-resources-without-using-eclipse)
    )

Hi Daniel,

Yes at the moment, I just use the OBB files so that while developing I don’t have to upload a big APK to my tablet, each time I make some changes (because the I need 600mb of compressed data: world terrain elevation data). Later on when my app is ready I will see how this licensing and download library work.

Thanks to your tips I discovered the library did not get included, and solved it by including the sources as descibed above. I don’t know if this is the best way. You mention a compiled library. When I download with the SdkManager the library is not compiled yet. Should I compile it seperately with an ant script, and then add it to my project? How would I do that?

Karel.

Hi Karel,

you did everything correct. When I read your post, I did not know whether
the library you needed was source or compiled. No need to change your
approach.

Talking about distribution later, I also have incorporated the licensing &
download library in my project, but I have a feeling (which I cannot
confirm) that not a lot of apps actually do that. They rely on Google Play
to do the initial download, and assume that the files won’t ever be gone or
damaged. Just a feeling though.

Regards,

Daniel

---------- Původní e-mail ----------
Od: Carlos El Fietro noreply@discourse.libsdl.org
Komu: hardcoredaniel@seznam.cz
Předmět: Re: [SDL] Android: “Could not access APK expansion support library”

"

 carloselfietro(https://discourse.libsdl.org/u/carloselfietro) 

August 31

Hi Daniel,

Yes at the moment, I just use the OBB files so that while developing I don’t
have to upload a big APK to my tablet, each time I make some changes
(because the I need 600mb of compressed data: world terrain elevation data).
Later on when my app is ready I will see how this licensing and download
library work.

Thanks to your tips I discovered the library did not get included, and
solved it by including the sources as descibed above. I don’t know if this
is the best way. You mention a compiled library. When I download with the
SdkManager the library is not compiled yet. Should I compile it seperately
with an ant script, and then add it to my project? How would I do that?

Karel.