cancel
Showing results for 
Search instead for 
Did you mean: 

Linking to OVRPlatform for in-app purchases in NDK app

spearson1128
Explorer
I have an NDK app (that uses VrAppInterface in C++) and I want to link to the platform library to add in-app purchase support. I thought I should simply be able to link to libovrplatform.so in Android/libs/armeabi-v7a and include svcjar.jar in my project, but it doesn't seem to work. I don't get any compile or link errors, but trying to link to it causes my main NDK module to not be built and included in the project, so I get a crash when the app loads due to the missing main module (saying that it couldn't find nativeOnStart). I'm using the experimental gradle plugin (0.7.0). I've tried linking using the following two methods. I've excluded the rest of the gradle file, but I've used these methods successfully to link to other libraries, such as fmod and libvrapi.so. As I said, I don't have any errors reported from the build. Has anyone successfully added IAP support to a native app?

model {
    android {
        ndk {
            ldLibs.addAll([..., "${file("path/to/libovrplatform.so")}".toString()])
        }
    }
}

And the following:

model {
    repositories {
        libs(PrebuiltLibraries) {
            ovrplatform {
                headers.srcDir "path/to/Include"
                binaries.withType(SharedLibraryBinary) {
                    sharedLibraryFile = file("path/to/libovrplatform.so")
                }
            }
        }
    }
    android.sources.main {
        jni {
            dependencies {
                library "ovrplatform" linkage "shared"
            }
        }
    }
}

1 REPLY 1

spearson1128
Explorer
I figured out how to fix the problem I was having. For the second method, in addition to the jni.dependencies block, I also added a jniLibs.dependencies block. It doesn't seem to work with just one of them. Also make sure you also include liboculus_p2p.so, and have svcjar.jar properly added in an outer dependency block. Here's the final gradle (using experimental plugin v0.7.0):

model {
    repositories {
        libs(PrebuiltLibraries) {
            ovrplatform {
                headers.srcDir "path/to/Include"
                binaries.withType(SharedLibraryBinary) {
                    sharedLibraryFile = file("path/to/libovrplatform.so")
                }
            }
            oculusp2p {
                headers.srcDir "path/to/Include"
                binaries.withType(SharedLibraryBinary) {
                    sharedLibraryFile = file("path/to/liboculus_p2p.so")
                }
            }
        }
    }
...
    android.sources.main {
        jni {
            dependencies {
                library "ovrplatform" linkage "shared"
                library "oculusp2p" linkage "shared"
            }
        }
        jniLibs {
            dependencies {
                library "ovrplatform"
                library "oculusp2p"
            }
        }
    }
}
dependencies {
    // Make sure svcjar.jar is in the following directory:
    compile fileTree(dir: 'libs', include: ['*.jar'])
...
}