Android - build project

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
andrew_vorobey
Gnoblar
Posts: 5
Joined: Sat Aug 20, 2016 3:21 pm

Android - build project

Post 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.
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Android - build project

Post 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...
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
farrer
Halfling
Posts: 64
Joined: Mon Sep 12, 2011 7:35 pm
x 13

Re: Android - build project

Post 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.
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Android - build project

Post 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...
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
andrew_vorobey
Gnoblar
Posts: 5
Joined: Sat Aug 20, 2016 3:21 pm

Re: Android - build project

Post by andrew_vorobey »

Thanks a lot!
This flag is exactly what I want.

Code: Select all

-DOGRE_BUILD_ANDROID_JNI_SAMPLE=true
Post Reply