Where are common bundle resources supposed to be put in Android?

I’m trying to fix this issue for real now because loading all of the FMOD banks into memory makes Android crash even with high compression Bundle Resources Android path (SOLVED)

I’m working a modified version of the FMOD example to try to get this to work

Here is current progress https://github.com/subsoap/defold-fmod

It works on Windows, but not on Android.

I tried to inspect the apk generated but it looks like it puts the banks folder in an unknown location or something?

I tried an armv7-android specific bundle resources folder but it did not work either.

I guess reading over the old thread again the problem is with the pathing when sending a relative path to the native extension on Android like @britzl said. So I need to be able to figure out an absolute path, and then send that to the native extension.

I’m not an Android expert so I’m not sure what to use to get the full path to build an absolute path to the banks to. I’m not sure if that will even work! :slight_smile: Will begin some tests soon. I think I need to make a mini native extension to use this code?

Didn’t Sergey create an extend for this already?

This one? https://github.com/Lerg/extension-directories

Ah yes that was the one I was thinking of.

Seems to work with bundling for Windows but not for Android.

Example of a path, what’s missing?

05-05 21:26:14.516 18438 18480 W defold  : WARNING:CRASH: Number of modules exceeds capacity: com.example.todo
05-05 21:26:14.518 18438 18480 I defold  : INFO:DLIB: Log server started on port 40278: com.example.todo
05-05 21:26:14.545 18438 18480 I defold  : INFO:ENGINE: Engine service started on port 8001: com.example.todo
05-05 21:26:14.545 18438 18480 I defold  : INFO:ENGINE: Defold Engine 1.2.152 (11b1e76): com.example.todo
05-05 21:26:14.550 18438 18480 I defold  : INFO:DIRECTORIES: APP_INITIALIZE: com.example.todo
05-05 21:26:14.555 18438 18480 I defold  : INFO:ENGINE: Loading data from: dmanif:game.dmanifest: com.example.todo
05-05 21:26:14.569 18438 18480 I defold  : INFO:DIRECTORIES: INITIALIZE: com.example.todo
05-05 21:26:14.609 18438 18480 I defold  : INFO:ENGINE: Initialised sound device 'default': com.example.todo
05-05 21:26:14.609 18438 18480 I defold  : : com.example.todo
05-05 21:26:14.626 18438 18480 D defold  : DEBUG:SCRIPT: : com.example.todo
05-05 21:26:14.626 18438 18480 D defold  : { --[[0xdf6536f0]]: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   api_version = "28",: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   device_model = "SM-G950U",: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   system_name = "Android",: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   ad_ident = "a988e6e3-d6f0-4743-80c6-1c19ebc51956",: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   ad_tracking_enabled = true,: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   user_agent = "",: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   gmt_offset = -420,: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   territory = "US",: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   device_ident = "30bafac118d38798",: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   device_language = "en",: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   manufacturer = "samsung",: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   system_version = "9",: com.example.todo
05-05 21:26:14.626 18438 18480 D defold  :   language = "en": com.example.todo
05-05 21:26:14.626 18438 18480 D defold  : }: com.example.todo
05-05 21:26:14.627 18438 18480 D defold  : DEBUG:SCRIPT: /data/app/com.example.todo-988RMMrFQna9kjw_7u6qbg==/base.apk/banks/Master Bank.bank: com.example.todo
05-05 21:26:14.688 18438 18480 E defold  : ERROR:SCRIPT: File not found.: com.example.todo
05-05 21:26:14.688 18438 18480 E defold  : stack traceback:: com.example.todo
05-05 21:26:14.688 18438 18480 E defold  : 	[C]: in function 'load_bank_file': com.example.todo
05-05 21:26:14.688 18438 18480 E defold  : 	main/main.script:48: in function <main/main.script:17>: com.example.todo
05-05 21:26:14.688 18438 18480 W defold  : WARNING:ENGINE: Unknown Android input method [KeyEvent], defaulting to key events: com.example.todo
05-05 21:26:14.689 18438 18480 E defold  : ERROR:SCRIPT: main/main.script:77: attempt to index local 'attr' (a nil value): com.example.todo
05-05 21:26:14.689 18438 18480 E defold  : stack traceback:: com.example.todo
05-05 21:26:14.689 18438 18480 E defold  : 	main/main.script:77: in function 'update_attributes': com.example.todo
05-05 21:26:14.689 18438 18480 E defold  : 	main/main.script:86: in function <main/main.script:82>: com.example.todo
05-05 21:26:14.711 18438 18480 I defold  : INFO:DLIB: SSDP: Started on address 192.168.0.104: com.example.todo
05-05 21:26:14.713 18438 18480 E defold  : ERROR:SCRIPT: main/main.script:77: attempt to index local 'attr' (a nil value): com.example.todo
05-05 21:26:14.713 18438 18480 E defold  : stack traceback:: com.example.todo
05-05 21:26:14.713 18438 18480 E defold  : 	main/main.script:77: in function 'update_attributes': com.example.todo
05-05 21:26:14.713 18438 18480 E defold  : 	main/main.script:86: in function <main/main.script:82>: com.example.todo
05-05 21:26:14.722 18438 18480 E defold  : ERROR:SCRIPT: main/main.script:77: attempt to index local 'attr' (a nil value): com.example.todo
05-05 21:26:14.722 18438 18480 E defold  : stack traceback:: com.example.todo

For our internal GetApplicationSupportPath() on Android, it looks like this.
(Not sure if you’re helped by that?)

    Result GetApplicationSupportPath(const char* application_name, char* path, uint32_t path_len)
    {
        ANativeActivity* activity = g_AndroidApp->activity;
        JNIEnv* env = 0;
        activity->vm->AttachCurrentThread( &env, 0);

        jclass activity_class = env->FindClass("android/app/NativeActivity");
        jmethodID get_files_dir_method = env->GetMethodID(activity_class, "getFilesDir", "()Ljava/io/File;");
        jobject files_dir_obj = env->CallObjectMethod(activity->clazz, get_files_dir_method);
        jclass file_class = env->FindClass("java/io/File");
        jmethodID getPathMethod = env->GetMethodID(file_class, "getPath", "()Ljava/lang/String;");
        jstring path_obj = (jstring) env->CallObjectMethod(files_dir_obj, getPathMethod);

        Result res = RESULT_OK;

        if (path_obj) {
            const char* filesDir = env->GetStringUTFChars(path_obj, NULL);

            if (dmStrlCpy(path, filesDir, path_len) >= path_len) {
                res = RESULT_INVAL;
            }
            env->ReleaseStringUTFChars(path_obj, filesDir);
        } else {
            res = RESULT_UNKNOWN;
        }
        activity->vm->DetachCurrentThread();
        return res;
    }
1 Like