Skip to main content
New Participant
September 15, 2023

Compile OpenXR SDK to .so file for Android Application

hello everyone, I want to make an Android application that run on Oculus Quest 2, the App need to get the key event and headset event. So I want to compile OpenXR SDK to .so file so that my android app can use it. Is that right ?

Thank you for your reply.

1 reply

New Participant
September 15, 2023

my code is :

std::shared_ptr<Options> options = std::make_shared<Options>();
        if (!UpdateOptionsFromSystemProperties(*options)) {
            return 1;
        }
        std::shared_ptr<PlatformData> data = std::make_shared<PlatformData>();
        data->applicationVM = context.Vm;
        data->applicationActivity = context.ActivityObject;
        bool requestRestart = false;
        bool exitRenderLoop = false;
        
        // Create platform-specific implementation.
        std::shared_ptr<IPlatformPlugin> platformPlugin = CreatePlatformPlugin(options, data);
        // Create graphics API implementation.
        std::shared_ptr<IGraphicsPlugin> graphicsPlugin = CreateGraphicsPlugin(options, platformPlugin);
        // Initialize the OpenXR program.
        std::shared_ptr<IOpenXrProgram> program = CreateOpenXrProgram(options, platformPlugin, graphicsPlugin);
        // Initialize the loader for this platform
        PFN_xrInitializeLoaderKHR initializeLoader = nullptr;
        if (XR_SUCCEEDED(
                xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction*)(&initializeLoader)))) {
            XrLoaderInitInfoAndroidKHR loaderInitInfoAndroid = {XR_TYPE_LOADER_INIT_INFO_ANDROID_KHR};
            loaderInitInfoAndroid.applicationVM = context.Vm;
            loaderInitInfoAndroid.applicationContext = context.ActivityObject;
            initializeLoader((const XrLoaderInitInfoBaseHeaderKHR*)&loaderInitInfoAndroid);
        }
        LOGI("Create instance");
        program->CreateInstance();

when run to CreateInstance()

    void CreateInstance() override {
        LogLayersAndExtensions();
        CreateInstanceInternal();
        LogInstanceInfo();
    }

when run in the LogLayersAndExtensions() Func , it show the error like this :