# Android .so for Unity

**URL:** https://discourse.kitware.com/t/android-so-for-unity/510
**Category:** Pulse Physiology Engine
**Created:** [July 24, 2020, 1:01pm UTC](https://discourse.kitware.com/t/android-so-for-unity/510 "2020-07-24T13:01:30Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![vascoptorres](https://discourse.kitware.com/user_avatar/discourse.kitware.com/vascoptorres/32/319_2.png) [@vascoptorres](https://discourse.kitware.com/u/vascoptorres)
#### Post date: [July 24, 2020, 1:01pm UTC](https://discourse.kitware.com/t/android-so-for-unity/510/1 "2020-07-24T13:01:30Z")

</div>

@abray, I wanted to DM you but it seems like I can’t probably because I just created my account.

I saw your comments on other threads on your progress for a .so to be used inside Unity. I have tried to use the JNI that’s on the engine repo but I couldn’t create the .so

Can you point me to how you did it, or maybe get me a working .so? I can then try to make it work inside Unity.

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [July 24, 2020, 1:13pm UTC](https://discourse.kitware.com/t/android-so-for-unity/510/2 "2020-07-24T13:13:43Z")

</div>

Pulse is a C++ engine, and I encapsulate all of the C++ API into a central PulseC library  
This PulseC library is used as the middle man between Java, C# and Python API’s

I have built several PulseC.so files here  
[https://data.kitware.com/#collection/59849c788d777f7d33e9c084/folder/5da739b0d35580e6dc9e9c79](https://data.kitware.com/#collection/59849c788d777f7d33e9c084/folder/5da739b0d35580e6dc9e9c79)

You can grab any of the 3.0.1 or 3.0.2 versions

To make these libraries I am cross compiling Pulse with [dockcross dockers](https://hub.docker.com/u/dockcross)  
But I have all that setup, so if you look at those dockers and figure out which is the appropriate one to build against for android, I can do it

---

<div class="post-metadata">

### Author: ![vascoptorres](https://discourse.kitware.com/user_avatar/discourse.kitware.com/vascoptorres/32/319_2.png) [@vascoptorres](https://discourse.kitware.com/u/vascoptorres)
#### Post date: [July 24, 2020, 2:40pm UTC](https://discourse.kitware.com/t/android-so-for-unity/510/3 "2020-07-24T14:40:01Z")

</div>

They don’t have Android armv7 on those dockers…

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [July 24, 2020, 4:54pm UTC](https://discourse.kitware.com/t/android-so-for-unity/510/4 "2020-07-24T16:54:54Z")

</div>

I suppose my biggest issue is finding the proper platform to compile Pulse to get an android compliant library.

What I did before, was use the Magic Leap SDK to cross compile Pulse for its LuminOS which seems to be an android variant. I suppose I could just do that again as I cannot seem to find any other docker image to build on.

I did find this:

> **[Build an Android app with Docker: build, push and pull docker image.](https://medium.com/@AndreSand/building-android-with-docker-8dbf717f54d4)**
>
> Check out this tutorial to get started with Docker:

And maybe I can just build this docker container and build on it.  
It seems like an android arm7 container is just a linux container with the Android SDK put on it  
Which is what the dockcross android-arm container is ([debian stretch](https://wiki.debian.org/ArmHardFloatPort))  
So I would think my Android-ARM/PulseC.so would work on Android ARMv7 devices

I am pretty confused as to how to build a compatible library.

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [July 24, 2020, 4:59pm UTC](https://discourse.kitware.com/t/android-so-for-unity/510/5 "2020-07-24T16:59:42Z")

</div>

Maybe all I need to do is update [this version](https://github.com/dockcross/dockcross/blob/master/android-arm/Dockerfile#L21) to pull a version of the NDK for ARMv7 compatibility

---

<div class="post-metadata">

### Author: ![vascoptorres](https://discourse.kitware.com/user_avatar/discourse.kitware.com/vascoptorres/32/319_2.png) [@vascoptorres](https://discourse.kitware.com/u/vascoptorres)
#### Post date: [July 24, 2020, 5:15pm UTC](https://discourse.kitware.com/t/android-so-for-unity/510/6 "2020-07-24T17:15:02Z")

</div>

I tried all the libraries, the Magic Leap one as well and I couldn’t get it to work. I am not experienced in building these libraries either. These docker images create the JNI automatically?

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [July 24, 2020, 5:50pm UTC](https://discourse.kitware.com/t/android-so-for-unity/510/7 "2020-07-24T17:50:22Z")

</div>

Oh yeah, I guess I misspoke in my earlier post

PulseC.so is for C# and Python  
PulseJNI.so if for Java

But they both use the same ‘thunk’ class internally, just expose it differently

The dockers only contain the compiler for the target platform  
The dockers then build the Pulse code base on your host system using the compiler they have inside the docker, and they write the output back to your host machine  
So the resulting PulseC.so and PulseJNI.so is built for the docker platform that you used

I am going to try to update the android-arm docker with the latest NDK and see how that works
