Forum Discussion

shaonD's avatar
shaonD
Honored Guest
9 years ago

Android Studio new c++ class add

I have create a new Empty Native Application Project using Oculus mobile SDK and Android studio, which is working fine. Its run in mobile with green screen.
I have created a new class (MyCube.cpp and MyCube.h), 
But when I am trying to access the new class from OvrApp.cpp, Its saying 'Error:error: undefined reference to 'MyCube::MyCube()''

Where I have to listed this new class file?

For native android app (Which was created by android studio), I had to declare the class in CMakeLists.txt 
But for Oculus mobile sdk I dont know where I have declare my new class.
Any Help??

2 Replies

  • If you have an Android.mk file you can add all the cpp files to LOCAL_SRC_FILES. For example, the Oculus360Photos native sample has the following:
    LOCAL_SRC_FILES :=	../../../Src/Oculus360Photos.cpp \
         ../../../Src/FileLoader.cpp \
         ../../../Src/PanoBrowser.cpp \
         ../../../Src/PanoMenu.cpp \
         ../../../Src/PhotosMetaData.cpp \
         ../../../Src/OVR_TurboJpeg.cpp
    If you don't have one, but have a build.gradle file, then place the cpp/h files in the jni directory. For the experimental gradle plugin, that's the path specified at model.android.sources.main.jni.source.srcDirs. I can't remember what it was for the non-experimental one. If the path isn't specified, I believe it defaults to the directory jni under your src/main directory.
  • shaonD's avatar
    shaonD
    Honored Guest
    Hi, Thanks for your help, I have found Android.mk under jni folder. Yup declared the class the way you say and it works