# Android Native Activity Support

**URL:** <https://discourse.libsdl.org/t/android-native-activity-support/21980>\
**Category:** SDL Development\
**Created:** [October 26, 2016, 8:11am UTC](https://discourse.libsdl.org/t/android-native-activity-support/21980 "2016-10-26T08:11:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![maartenengels](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/f0a364/32.png) [@maartenengels](https://discourse.libsdl.org/u/maartenengels)\
**Post date:** [October 26, 2016, 8:11am UTC](https://discourse.libsdl.org/t/android-native-activity-support/21980/1 "2016-10-26T08:11:20Z")

</div>

Hello guys,

For the last month I have been doing my research on the best way to port my C++ project to android, and the most elegant way I found is using “Android Studio” with “Native Activity”.

Unfortunately, I see that this is not supported by SDL(I understand that before September this was experimental so I can understand why might had not been supported). So my Questions are:

- Is it in the plans to support the “Native Activity” build?
- If yes then when?(So should I wait a couple months, or move to something else.)

Thanks before hand for you answers.

---

<div class="post-metadata">

**Author:** ![GameCodingNinja](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/gamecodingninja/32/3102_2.png) [@GameCodingNinja](https://discourse.libsdl.org/u/GameCodingNinja)\
**Post date:** [October 29, 2016, 5:45pm UTC](https://discourse.libsdl.org/t/android-native-activity-support/21980/2 "2016-10-29T17:45:50Z")

</div>

In my experience, Android Studio’s native compile is gimped due to their “experimental gradle”. I have not been able to get it to work corectly. This has nothing to do with SDL supporting “Native Activity”.

This is what you should try to do first. In the SDL/docs folder is a file called [README-android.md](http://README-android.md). This assumes you are trying to build your Android files on Linux. The read-me shows you how to use the provided scripts to build an Android project and deploy it on your Android device with Ant. It’s actually quite simple to do and if you can get the sample project to compile and deploy it to your phone and see it working, then it’s just a matter of using that project as a template for your game.

---

<div class="post-metadata">

**Author:** ![maartenengels](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/f0a364/32.png) [@maartenengels](https://discourse.libsdl.org/u/maartenengels)\
**Post date:** [October 31, 2016, 9:22am UTC](https://discourse.libsdl.org/t/android-native-activity-support/21980/3 "2016-10-31T09:22:50Z")

</div>

Hello @GameCodingNinja,

I am currently doing it the crapy way that I found on the readme file, with no IDE and no debugging. But thats not ideal.

"Native Activity is not supported by SDL, and has nothing to do with gradle. It is C++ and CMake, all my libraries build and the project compiles but when you try to do SDL\_Init you can’t, because it gives you an error that its missing the SDL\_main and from what I read I understand that I need SDL\_Activity to do that. So that really doesn’t feel efficient or ideal to me.

“Native Activity” is not based on an experimental gradle anymore it comes with Android Studio out of the box. Of course it has only been like that since September. So what I am wondering is if its is the plans to support the Native Activity way.

---

<div class="post-metadata">

**Author:** ![hardcoredaniel](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/h/9de053/32.png) [@hardcoredaniel](https://discourse.libsdl.org/u/hardcoredaniel)\
**Post date:** [November 27, 2016, 10:23am UTC](https://discourse.libsdl.org/t/android-native-activity-support/21980/4 "2016-11-27T10:23:15Z")

</div>

Well, if I understand things correctly, then “NativeActivity” is a simple  
"pre-compiled Java Activity" that native code might link against, if it  
wanted to avoid any Java coding. In that case, all Android lifecycle  
handling must be done in the native code as well (e.g. all the stuff that  
SDLActivity.java currently does would have to be ported, roughly speaking).  
Finally, there wouldn’t be much of a difference from a technical view, you  
would still build & run an app.

I don’t know how good debugging support for the native code is in Android  
Studio now, I was only using “ndk-gdb” from the command line.

Regards,

Daniel

---------- P?vodn? zpr?va ----------  
Od: maartenengels \<m.engels at [visualproductions.nl](http://visualproductions.nl)\>  
Komu: sdl at [lists.libsdl.org](http://lists.libsdl.org)  
Datum: 26. 11. 2016 22:38:05  
P?edm?t: Re: [SDL] Android Native Activity Support

"

Hello @GameCodingNinja,

I am currently doing it the crapy way that I found on the readme file, with  
no IDE and no debugging. But thats not ideal.

"Native Activity is not supported by SDL, and has nothing to do with gradle.  
It is C++ and CMake, all my libraries build and the project compiles but  
when you try to do SDL\_Init you can’t, because it gives you an error that  
its missing the SDL\_main and from what I read I understand that I need SDL\_  
Activity to do that. So that really doesn’t feel efficient or ideal to me.

“Native Activity” is not based on an experimental gradle anymore it comes  
with Android Studio out of the box. Of course it has only been like that  
since September. So what I am wondering is if its is the plans to support  
the Native Activity way.\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
SDL mailing list  
SDL at [lists.libsdl.org](http://lists.libsdl.org)  
[http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)"

---

<div class="post-metadata">

**Author:** ![maartenengels](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/f0a364/32.png) [@maartenengels](https://discourse.libsdl.org/u/maartenengels)\
**Post date:** [January 11, 2017, 8:44am UTC](https://discourse.libsdl.org/t/android-native-activity-support/21980/5 "2017-01-11T08:44:20Z")

</div>

Well you can include CMake list in your build, you can actually use Android studio to debug your application, you can handle files and other utilities directly from c++ without having to go to the java code.

I see a lot of + in this way.

Regards,

Michael

---

<div class="post-metadata">

**Author:** ![GameCodingNinja](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/gamecodingninja/32/3102_2.png) [@GameCodingNinja](https://discourse.libsdl.org/u/GameCodingNinja)\
**Post date:** [April 2, 2017, 5:46pm UTC](https://discourse.libsdl.org/t/android-native-activity-support/21980/6 "2017-04-02T17:46:41Z")

</div>

I don’t know. Your guess is as good as mine.
