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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Crynux

Pages: [1]
1
General discussions / Re: Android and iOS ports available for testing
« on: February 17, 2015, 09:37:19 am »
Had to make sure that in the AndroidManifest.xml,  android:hasCode="true"

Once that is set, the .class files are available, and I can access them through JNI!

2
General discussions / Re: Android and iOS ports available for testing
« on: February 17, 2015, 09:04:36 am »
Yep, it's not really made for that purpose (so far).

You can look into the Android specific code of SFML (src/SFML/window/Android) to see how you can call Java stuff from C++, although it's quite tricky and anything but clean.

I thought about creating an easier wrapper class to call Java stuff as an extension (not core SFML), but lack of time and too many other things to work on first.

Hmmm, I see.

I've tried a few things with the aim of executing some Java code, but so far it seems that either my Java .Class files aren't being loaded, or the Java VM handle/pointer/thing I get just doesn't know where they are. Any ideas? I've tried accessing the VM before the main function is called in MainAndroid.cpp [in void* main(ActivityStates* states)].

The .class files are in the .apk... I just don't know at what point they are loaded (or if they are loaded), and where that is in relation to the SFML entry point.

3
General discussions / Re: Android and iOS ports available for testing
« on: February 17, 2015, 07:49:30 am »
Yeah, I was thinking that too, but if going from a Java standpoint, I don't know how to get SFML running on a Java-based Activity. I've tried a few things, but no luck. So at this point I'm assuming that for SFML, you'd have to call Java from the C/C++ code.

4
General discussions / Re: Android and iOS ports available for testing
« on: February 17, 2015, 07:11:47 am »
I've been trying for the past few days to access a Java class from Android SFML. So far, I've tried to get access to JavaVM and/or JNIEnv, but for some reason it cannot find my Java class (It's in the apk and such).

My goal is to use SFML for graphics, but I have an Android library that I'm using which requires the use of Java.

Anyone have any pointers for how/where to call a Method from a Java class using SFML for Android? Or is it not possible at this point?

Thanks in advance for any help.

5
General / 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.


Pages: [1]
anything