# can I package ue4 project into so and call methods from android apps?

**URL:** <https://forums.unrealengine.com/t/can-i-package-ue4-project-into-so-and-call-methods-from-android-apps/69262>\
**Category:** Mobile\
**Tags:** unreal-engine, Android\
**Created:** [July 18, 2016, 11:24am UTC](https://forums.unrealengine.com/t/can-i-package-ue4-project-into-so-and-call-methods-from-android-apps/69262 "2016-07-18T11:24:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_cc5e35bc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cc5e35bc](https://forums.unrealengine.com/u/anonymous_user_cc5e35bc)\
**Post date:** [July 18, 2016, 11:24am UTC](https://forums.unrealengine.com/t/can-i-package-ue4-project-into-so-and-call-methods-from-android-apps/69262/1 "2016-07-18T11:24:59Z")

</div>

As described in the title. I noticed that when package project as apk, it can generate some so files, I wonder how to write the android java part by my self and call the method from the so files. Is there and guide or something ? I know there are related files in Source\Runtime\Launch , but the logic is complicated for begineer, and I don’t know how these files organized as being called by java. Can anybody knows help me? Thanks.

---

<div class="post-metadata">

**Author:** ![Chris\_Babcock](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chris\_Babcock](https://forums.unrealengine.com/u/Chris_Babcock)\
**Post date:** [July 18, 2016, 5:33pm UTC](https://forums.unrealengine.com/t/can-i-package-ue4-project-into-so-and-call-methods-from-android-apps/69262/2 "2016-07-18T17:33:48Z")

</div>

All the Java code is in Engine/Build/Android/Java/src. You can put your own Java code in your project’s Build/Android/src directory with the package name sections as subdirectories. As for calling your Java functions, take a look at AndroidJavaMediaPlayer.cpp; it wraps access to MediaPlayer14.java.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cc5e35bc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cc5e35bc](https://forums.unrealengine.com/u/anonymous_user_cc5e35bc)\
**Post date:** [July 19, 2016, 3:43am UTC](https://forums.unrealengine.com/t/can-i-package-ue4-project-into-so-and-call-methods-from-android-apps/69262/3 "2016-07-19T03:43:45Z")

</div>

I found that there is a .so file generated with apk file, what does this .so file do? Could I develop base on this file in android? what header files should I include in my c++ file part to use this .so file ?

---

<div class="post-metadata">

**Author:** ![Chris\_Babcock](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chris\_Babcock](https://forums.unrealengine.com/u/Chris_Babcock)\
**Post date:** [July 19, 2016, 4:02pm UTC](https://forums.unrealengine.com/t/can-i-package-ue4-project-into-so-and-call-methods-from-android-apps/69262/4 "2016-07-19T16:02:53Z")

</div>

The libUE4.so is the C++ part of the engine (the majority of the code for Android; Java is only the minimum needed). You can generate a code project and add your own C++ code and it will be compiled into this .so.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cc5e35bc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cc5e35bc](https://forums.unrealengine.com/u/anonymous_user_cc5e35bc)\
**Post date:** [July 20, 2016, 5:34am UTC](https://forums.unrealengine.com/t/can-i-package-ue4-project-into-so-and-call-methods-from-android-apps/69262/5 "2016-07-20T05:34:14Z")

</div>

so whatever c++ code I write in my project will be packaged into libUE4.so, and I just need to writing other c++ code and native signature as usual?  
one more question: why I can’t use the command “nm libUE4.so” to check the function names in the file?  
Thanks!

---

<div class="post-metadata">

**Author:** ![Chris\_Babcock](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chris\_Babcock](https://forums.unrealengine.com/u/Chris_Babcock)\
**Post date:** [July 20, 2016, 6:48pm UTC](https://forums.unrealengine.com/t/can-i-package-ue4-project-into-so-and-call-methods-from-android-apps/69262/6 "2016-07-20T18:48:47Z")

</div>

“nm --demangle -D libUE4.so” works fine for me.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cc5e35bc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cc5e35bc](https://forums.unrealengine.com/u/anonymous_user_cc5e35bc)\
**Post date:** [July 22, 2016, 1:56am UTC](https://forums.unrealengine.com/t/can-i-package-ue4-project-into-so-and-call-methods-from-android-apps/69262/7 "2016-07-22T01:56:50Z")

</div>

you really helped me out, Chris! Now I get a new problem: what should I do to get back to the activity that I created when press back, I tried onKeyDown() and onBackPressed() in GameActivity and it didn’t work, I check the log that system says I pressed the button but the two function were not called.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cc5e35bc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cc5e35bc](https://forums.unrealengine.com/u/anonymous_user_cc5e35bc)\
**Post date:** [July 22, 2016, 6:48am UTC](https://forums.unrealengine.com/t/can-i-package-ue4-project-into-so-and-call-methods-from-android-apps/69262/8 "2016-07-22T06:48:18Z")

</div>

I worked it out, I modified the LaunchAndroid.cpp’s return value in line 655, and called some functions in GameActivity.AndroidThunkJava\_ForceQuit(), now I can write onKeyDown() and return to my activity!  
ps: I found that it’s you who write the LaunchAndroid.cpp！！！
