Page 1 of 1

Android - build project

Posted: Sat Aug 20, 2016 3:45 pm
by andrew_vorobey
Hello!
I've build the ogre with: http://www.ogre3d.org/tikiwiki/tiki-ind ... on=Android. A get the apk file from the build and it was successfully running on android.
I'm following the tutorial and successfully building tutorial project on my ubuntu.
Now I want to build it(project) for android, but I don't know how cat I do this.

I've tried to make project on Android studio, added project sources as jni sources, added ogre build libs as jnilibs, get android.mk file and application.mk file from the ogre build folder.
But for now build is not successful: At start, android doesn't know where ogre headers is. As fast work around I've added full path to include files. For now error in OgreStdHeaders.h - it want to include vector, map and ect, but android studio doesn't know what is it.
I tried ndk r10b and r12b, I tried

Code: Select all

APP_STL := gnustl_static
in application.mk, but it all useless.

So, the question is "how can I build my app for android?".
The ideal variant is: build project to .so or .o file without android studio, and create .cpp jni file to call ogre project functions from android project.
I know how to make jni layer, but i don't know how to build ogre project to android compatible lib.

Re: Android - build project

Posted: Sat Aug 20, 2016 6:59 pm
by frostbyte
dont remember the details( did it 6 month ago ) but just tweaking sampleBrowser android build scripts to my project paths did the trick for me...

Re: Android - build project

Posted: Sun Aug 21, 2016 11:12 am
by farrer
Or you could compile the JNI sample (adding

Code: Select all

-DOGRE_BUILD_ANDROID_JNI_SAMPLE=true
when configuring Ogre build) and adapt its code (it just starts Ogre and changes the viewport color to red) and build environment to your projects.

Re: Android - build project

Posted: Sun Aug 21, 2016 6:53 pm
by frostbyte
farrer is right- now i remember how i did it( thanks farrer... )
like farrer suggested i used the ANDROID_JNI_SAMPLE( much simpler code then sampleBrowser ) and tweaked it to start my project, however...
ANDROID_JNI_SAMPLE does'nt have RTShader build-in, so all meshes are renderered without materials.
so i borrowed the RTShader declaration and initialazation from SampleBrowser( remember it was'nt that easy... )
since then HLMS-PBS became available for ogre1.10, so now you can use it instead of RTShader if you preffer PBS( there is a hlms sample )
this was quite a trip( took me a while to find out why all is black ) - i never thought seing OgreHead being rendered can give me so much joy (-:

i can also recommend you to use "Andy"- simply the best android-arm-VM out there, just don't use googles emulator...

Re: Android - build project

Posted: Sun Aug 21, 2016 9:35 pm
by andrew_vorobey
Thanks a lot!
This flag is exactly what I want.

Code: Select all

-DOGRE_BUILD_ANDROID_JNI_SAMPLE=true