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

Author Topic: Build SFML to Android-Port with VS 2015  (Read 5477 times)

0 Members and 1 Guest are viewing this topic.

Hlymur

  • Newbie
  • *
  • Posts: 3
    • View Profile
Build SFML to Android-Port with VS 2015
« on: March 28, 2016, 03:39:12 pm »
Hey @all,

at first let me point out, that i'm new to this forum (forwarded from the german SFML-forum) and maybe this topic need to be moved!
Microsoft introduced native-android-development with VS 2015. I tried to build the SFML-libs with VS 2015 but had no success.
I tried some different "google-results", but nothing worked:
I've used this tutorial with the following result:
Code: [Select]
CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR specifies a platform to: 'Visual Studio 14 2015 ARM'
Next, i found an interesting MS-article, about a patched CMake-Version.
By following the steps, CMake starts working, but i got this error-msg:
Code: [Select]
CMake Error at src/SFML/Graphics/CMakeLists.txt:119 (find_host_package):
Unknown CMake command "find_host_package".
By using this command:
Code: [Select]
cmake -G "Visual Studio 14 2015 ARM" -DCMAKE_SYSTEM_NAME=VCMDDAndroid -DANDROID_ABI=armeabi -DANDROID_NDK=C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e ..\..
I'm not that familiar with CMake to fix this error. So maybe u can help me?  :)

Or at least u've some tips or experience building SFML to Android with VS 2015.

Also i could use Android Studio, but i don't like the eclipse-like IDE, but if its more easier, i would try it ;-)

thanks!

Hlymur

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Build SFML to Android-Port with VS 2015
« Reply #1 on: March 29, 2016, 12:33:42 pm »
VS2015's android support is raw and awful. Use this - https://developer.nvidia.com/nvidia-nsight-tegra
Forum - https://devtalk.nvidia.com/default/board/82/nsight-tegra-visual-studio-edition/1/
Example of SFML VS project is here - https://bitbucket.org/SteelRat/gipe/src/725d1a1242ff/deps/sfml/
It's for old Nsight version and for VS2013, but I think it's good as example.

Hlymur

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Build SFML to Android-Port with VS 2015
« Reply #2 on: March 29, 2016, 04:15:16 pm »
thx, that helps a lot!

With Nsight Tegra i compiled the SFML-libs!

Next, i created a test-project (New Project > Nsight Tegra > Android Native Application).
I've deleted the "glue"-Files, add the include and lib paths to the project and put following code to the main.cpp:
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main( int argc , char *argv[] )
{
        sf::RenderWindow window{ sf::VideoMode::getDesktopMode() , "" };

        sf::RectangleShape shape;

        shape.setSize( { 100.f,100.f } );
        shape.setFillColor( sf::Color::Red );
        shape.setPosition( 10.f , 10.f );

        sf::View view = window.getDefaultView();

        while( window.isOpen() )
        {
                sf::Event event;

                while( window.pollEvent( event ) )
                {
                        if( event.type == sf::Event::Closed )
                        {
                                window.close();
                        }

                        if( event.type == sf::Event::Resized )
                        {
                                view.setSize( event.size.width , event.size.height );
                                view.setCenter( event.size.width / 2 , event.size.height / 2 );
                                window.setView( view );
                        }
                }


                window.clear( sf::Color::White );
                window.draw( shape );
                window.display();
        }
}
 

Last, i edited the AndroidManifest.xml:
  • add this line: <uses-feature android:glEsVersion="0x00010001" />
  • change <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="21" /> to <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
  • add this line: <meta-data android:name="android.app.lib_name" android:value="sfml-activity" />, by removing the old one

After compiling i got 3 Files:
"libSFML_Android_Test.so"
"SFML_Android_Test.apk"
"stripped_libSFML_Android_Test.so"

I copiedthis 3 files to my mobile-device and installed the .apk-file.
When i try to start the application i got the message, that the program has terminated.

I guess i need to copy the .so-files (including the sfml-libs) to a special place, but i don't know where :-S
On the other hand, .apk's i've already installed in my life never needn't to copy a shared-lib to a special place :(

Hlymur

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Build SFML to Android-Port with VS 2015
« Reply #3 on: March 30, 2016, 05:26:10 pm »
Today i build the sfml-android-sample (with Commandline).

When i try to run the app on my device i got the message "Unfortunately, SFML has stopped."
Any ideas how to fix it?

PS: I followed these steps to build the example

 

anything