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

Author Topic: Android support  (Read 1258 times)

0 Members and 1 Guest are viewing this topic.

wdmitry

  • Newbie
  • *
  • Posts: 16
    • View Profile
Android support
« on: November 19, 2023, 10:01:26 pm »
I find some very old articles of people tried to build this thing up for android.
Is there any Android support at all? Tutorials?


Thrasher

  • SFML Team
  • Jr. Member
  • *****
  • Posts: 53
    • View Profile
Re: Android support
« Reply #1 on: November 19, 2023, 10:42:56 pm »
Yes we actively maintain Android support and have a few users who routinely provide bug fixes and other enhancements

wdmitry

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android support
« Reply #2 on: November 20, 2023, 12:12:15 pm »
I am trying to compile hello world for android. Are there any updated tutorials?

texus

  • Hero Member
  • *****
  • Posts: 501
    • View Profile
    • TGUI
    • Email
Re: Android support
« Reply #3 on: November 20, 2023, 12:33:50 pm »
Are you following https://github.com/SFML/SFML/wiki/Tutorial%3A-Building-SFML-for-Android ?

Where are you stuck exactly?
TGUI: C++ SFML GUI

wdmitry

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android support
« Reply #4 on: November 20, 2023, 02:55:49 pm »
Hm, this one I didn't follow. let me try. I tried to setup with android studio.

I did run this command additionally to install sfml to ndk
```
cmake -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK=/android-ndk-r25c -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_ANDROID_STL_TYPE=c++_static -DCMAKE_BUILD_TYPE=Debug ../..
```

Here what I get at the last command:
```
> Task :app:configureCMakeDebug[arm64-v8a] FAILED
C/C++: CMake Error at CMakeLists.txt:10 (find_package):
C/C++:   By not providing "FindSFML.cmake" in CMAKE_MODULE_PATH this project has
C/C++:   asked CMake to find a package configuration file provided by "SFML", but
C/C++:   CMake did not find one.
C/C++:   Could not find a package configuration file provided by "SFML" (requested
C/C++:   version 3) with any of the following names:
C/C++:     SFMLConfig.cmake
C/C++:     sfml-config.cmake
C/C++:   Add the installation prefix of "SFML" to CMAKE_PREFIX_PATH or set
C/C++:   "SFML_DIR" to a directory containing one of the above files.  If "SFML"
C/C++:   provides a separate development package or SDK, be sure it has been
C/C++:   installed.

```
« Last Edit: November 20, 2023, 02:57:28 pm by wdmitry »

texus

  • Hero Member
  • *****
  • Posts: 501
    • View Profile
    • TGUI
    • Email
Re: Android support
« Reply #5 on: November 20, 2023, 03:05:01 pm »
After running "make install" when building SFML, the SFML files should have been installed to the "sources/third_party/sfml" folder inside your NDK. First double check that the files exist there.

The last part of the tutorial is slightly outdated as it is still written for SFML 2, for SFML 3 you need to edit the "app/gradle.build.kts" file inside the android example. At the top of the file it sets a default NDK_VERSION and ARCH_ABI. If either of these is wrong then it will fail to find SFML with the error that you showed. So you need to change the NDK_VERSION from "25.2.9519653" to the version where SFML was installed to, and change ARCH_ABI from "arm64-v8a" to whatever you set CMAKE_ANDROID_ARCH_ABI to when building SFML (which is "armeabi-v7a" in the tutorial).

Edit: Are you using the NDK installed with the sdkmanager? The CMAKE_ANDROID_NDK is usually "<ANDROID_SDK_ROOT>/ndk/25.2.9519653" (where you replace "<ANDROID_SDK_ROOT>").
« Last Edit: November 20, 2023, 03:09:40 pm by texus »
TGUI: C++ SFML GUI

wdmitry

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android support
« Reply #6 on: November 20, 2023, 03:13:03 pm »
I see it did install into a different ndk folder. I just copied it from there to the path it wants and now it works!
Yay!

wdmitry

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android support
« Reply #7 on: November 20, 2023, 10:05:15 pm »
was able to configure and compile my project for android, all works!
SFML3 rulz!

wdmitry

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android support
« Reply #8 on: November 22, 2023, 09:44:25 pm »
JNI undefined code indeed does crash.

Question: can sfml trigger input text on android system then?

texus

  • Hero Member
  • *****
  • Posts: 501
    • View Profile
    • TGUI
    • Email
Re: Android support
« Reply #9 on: November 22, 2023, 10:53:21 pm »
You can show the software keyboard with "sf::Keyboard::setVirtualKeyboardVisible(true)", if that is what you mean with triggering input text.
TGUI: C++ SFML GUI

8Observer8

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • My website
    • Email
Re: Android support
« Reply #10 on: February 08, 2024, 01:40:08 pm »
I have made a step-by-step instruction for Android: How to build SFML3 with gradlew for Android on Window 10 with MinGW

wdmitry

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Android support
« Reply #11 on: May 09, 2024, 01:16:18 pm »
what about the vibration activation?