Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Porting existing SFML code to work with Android [SOLVED]  (Read 1558 times)

0 Members and 1 Guest are viewing this topic.

Crynux

  • Newbie
  • *
  • Posts: 5
    • View Profile
Porting existing SFML code to work with Android [SOLVED]
« on: February 15, 2015, 05:02:35 am »
Hello all,

Over the past little while I've been developing an application that uses SFML for graphics and audio on Windows. Recently, it has been decided to try to port this same application to Android.

I've downloaded, compiled and ran the Android SFML example, along with the standard NDK examples; they run fine.

However, I've run into a few problems, I hope someone can help me or point me in the right direction:
  • My windows code consisted of essentially one C++ class. My first attempt in getting this class to work with Android SFML was to build it as a Shared Object, and simply use a header to access its methods. Unfortunately this didn't work... after some troubleshooting I found that if I (more or less) copied all of my code into the main() of the SFML example, it worked fine. Does Android SFML not support classes or code linked from other libraries? Whenever I try, I get a fatal sigsegv signal 11 error and it crashes.
  • The example given seems to only allow the use C/C++ code. Is there a way to call some Java code from the SFML Android main() function? If not, then is it possible to setup a normal Java Activity and call my SFML C/C++ code from it using JNI, allowing me to pass a Java value to it?

I've spent a few days working on this, and haven't found a solution yet. Any help or guidance would be greatly appreciated. I'm rather new to Android development, and have only been working with SFML for a few months; hopefully I'm not missing something simple!

EDIT: I should mention that my SFML code compiles and works fine on Windows and Linux.

Thank you in advance,
-Crynux

PS: If this post is not in the right area, I apologize.


SOLUTION:
After 6 hours of fiddling around with my code... I've found the problem. In the AndroidManifest.xml, you have to make sure android:hasCode="true". By default in the SFML Android example, it seems to be "false".

Once that is set, you can access custom Java classes using JNI; however, I won't go into detail regarding how I did that.

« Last Edit: February 17, 2015, 09:49:22 am by Crynux »

 

anything