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

Author Topic: Android Studio example project  (Read 4954 times)

0 Members and 1 Guest are viewing this topic.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Android Studio example project
« on: September 21, 2016, 07:32:17 pm »
Hello,

as the title says, it would be time for an example project for AndroidStudio (using Gradle) for SFML. I managed to port the android-sfml example to Android Studio 2.2 with Gradle Experimental 0.8.0/2.14.2. It would be nice if you could test it, and give some feedback.

https://github.com/AlexAUT/SFML-AndroidStudio-Template there is a HowTo at the Github Site.

There are currently two problems which requires a fix by Google:
  • Because sfml-activity loads the user's code it's required that the whole sfml-main is available in the shared library file. With normal linkage basically everything from sfml-main gets thrown away by the linker, because no user code does reference any sfml-main's code. In ANT we have WHOLE_STATIC_LIB for this case, in Gradle there is no way to do this yet (see github). So I had to copy some implementation specific files to the userproject (SFMLHack folder). As soon as google supports the -Wl,--whole-archive linker option in the Gradle plugin I could remove these files.
  • Also there is currently no way to link the -d libraries when using a debug build, so the template will always link the release lib files.

If you have any questions about the build system, feel free to ask  :D

AlexAUT

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android Studio example project
« Reply #1 on: September 22, 2016, 10:02:07 am »
To be honest I'm still not really happy with the whole sfml-activity/sfml-main thing, because it makes building really ugly, yet I haven't found any time to adjust or rewrite any parts of that.

End goal would be being able to build and deploy with any IDE (including Visual Studio), especially for debugging purposes, using only a single shared library similar to normal "native activity "builds.

Just out of interest: How does building normal native activities work? IIRC they also require WHOLE_STATIC_LIB, don't they?

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Android Studio example project
« Reply #2 on: September 22, 2016, 11:07:28 am »
Yeah it's kinda strange how SFML loads the usercode. I don't think it's necessary, you could simply copy the content of the SFMLActivity.cpp to the MainAndroid.cpp (the onCreate function). Then SFML would not need to load all the dll itself, also the META data (lib_name) could then be removed. But we cannot link the part of SFML with the ANativeActivity functions dynamically because they need to be in the NDKModule loaded by the NativeActivity. And to make it work statically we would need a sfml_dummy function (see at the end of this post)

Is the VisualStudio for Android port really a thing? Last time i tried it, it was horrible (not talking about the tegra plugin)

Just out of interest: How does building normal native activities work? IIRC they also require WHOLE_STATIC_LIB, don't they?

If you talk about the native_app_glue, they link it statically and call the "app_dummy" function to prevent the stripping. See here


AlexAUT