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

Author Topic: Android and iOS ports available for testing  (Read 300184 times)

0 Members and 2 Guests are viewing this topic.

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #285 on: September 22, 2014, 04:46:17 pm »
There is problem with OpenAL again - crash on pressing "Home" button. Rebuilding last from openal-soft solves the problem. Hmm, it solves if openal was built on Linux, but not in Windows. =)
« Last Edit: September 22, 2014, 04:51:41 pm by ChronicRat »

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #286 on: September 28, 2014, 05:09:23 pm »
Looking for reason why segmentation fault on 4.0.4 and less. I tried to use std::thread and std::mutex. And found deadlock here:

EglContext::EglContext(EglContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel) :
m_display (EGL_NO_DISPLAY),
m_context (EGL_NO_CONTEXT),
m_surface (EGL_NO_SURFACE),
m_config  (NULL)
{
#ifdef SFML_SYSTEM_ANDROID

    // On Android, we must save the created context
    ActivityStates* states = getActivity(NULL);
    Lock lock(states->mutex);

    states->context = this;

#endif

    // Get the intialized EGL display
    m_display = states->display; // getInitializedDisplay() - this function locks locked states->mutex
 
« Last Edit: September 28, 2014, 09:12:08 pm by ChronicRat »

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #287 on: September 29, 2014, 07:29:15 pm »
Why dlclose can be called in the very begining of the program? It looks like some library has been unloaded. It happens on Android < 4.0.4 only. I don't what's happening. No ideas. I have no hardware device with 4.0.3, by some reason i can't debug on emulator when program just started.

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #288 on: September 30, 2014, 06:28:55 pm »
I don't know why but now after onPause and then returning to app called ANativeActivity_onCreate.
Something like this works for me:
if (!oldStates)
        {
                // Launch the main thread

                std::thread* thread = new std::thread(&sf::priv::main, states);
                //sf::Thread* thread = new sf::Thread(sf::priv::main, states);
        //    thread->launch();

                // Wait for the main thread to be initialized
                states->mutex.lock();

                while (!states->initialized)
                {
                        states->mutex.unlock();
                        sf::sleep(sf::milliseconds(20));
                        states->mutex.lock();
                }

                states->mutex.unlock();
                // Share this state with the callback functions
                activity->instance = states;
        }
        else
        {
                states->context = oldStates->context;
                states->forwardEvent = oldStates->forwardEvent;
                states->processEvent = oldStates->processEvent;
                free(oldStates->savedState);
                delete oldStates;
                initializeMain(states);
                // Share this state with the callback functions
                activity->instance = states;
        }
 

PS Anybody works with Android SFML?  :(

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: Android and iOS ports available for testing
« Reply #289 on: October 11, 2014, 03:25:25 pm »
Hi here,

I've been very busy lately and I couldn't work work on the Android port. I'm back now and I had time this week to make progress on your issues. Will reply shortly :)
Interested in using SFML with Python ? Try out its Python binding!

jd6

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Android and iOS ports available for testing
« Reply #290 on: October 27, 2014, 06:26:10 pm »
Hello,

I am trying to compile an SFML example on Android.

I use the android-ndk-r10b, the adt-bundle-windows-x86_64-20140702 with Qt 5.3.1 and I'm on Windows 7 Pro 64 bits.

I had no problems to compile SFML for Android.

However, when I want to run the SFML example on an AVD, I had a segfault :
(click to show/hide)

Why have I this error ? How can I resolve it ? Thanks in advance.

The SFML example :
(click to show/hide)


The .PRO file (I use qmake with QtCreator) :
(click to show/hide)


The Android Manifest File :
(click to show/hide)


P. S. : Why can't I create sf::String(const char*) ? I have read the cause is the std::locale, but how resolve it ?


If I forgot something, I can specify.


Best regards,


jd6.


P. S. 2 : I'm not english, so perhaps I made some mistakes. Do not hesitate to report me these. Thanks !


Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #291 on: October 27, 2014, 07:02:30 pm »
While Android doesn't support locales, you should still be able to use std::string just fine. In fact, your locale is simply locked to "C".

A bigger problem might be your use of a wide character string. The Android NDK's support for wide character strings is still very minimal and most stuff is simply broken or not implemented.

You could try debugging your app, just use the "ndk-gdb-py" script/batch file found in the NDK dir.

What happens if you don't use the QT stuff at all? Is there any reason to include it?

jd6

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Android and iOS ports available for testing
« Reply #292 on: October 27, 2014, 07:37:13 pm »
Thanks ! :)

When I replace my old sf::String(wchar_t*) by sf::String(std::string("test")), I had an error : undefined reference to 'sf::String::String(std::string const&, std::locale const&)'. Why had I this error ? I tried sf::String(std::string("test"), std::locale("C")), but it doesn't work. How can I resolve it ?

How can I do not use wide character string ? Thanks in advance for your response.

I use Qt to get its classes which can be useful. Likewise Qt supports Android easily. But I think I will try without Qt stuff. And I will try debugging like you say ("ndk-gdb-py") when this problems will be resolved.

In any case, thanks for your response !

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #293 on: October 27, 2014, 07:41:33 pm »
Just use "sf::String test("some text");" for now.

jd6

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Android and iOS ports available for testing
« Reply #294 on: October 27, 2014, 07:56:16 pm »
Thanks for your response ! :)

Unfortunately, it doesn't work :
main.obj:main.cpp:function main: error: undefined reference to 'sf::String::String(char const*, std::locale const&)'
collect2.exe: error: ld returned 1 exit status

The new code :
(click to show/hide)

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android and iOS ports available for testing
« Reply #295 on: October 27, 2014, 08:51:41 pm »
This is really weird. What happens without the QT header?

jd6

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Android and iOS ports available for testing
« Reply #296 on: October 27, 2014, 09:50:00 pm »
Without "#include <QCoreApplication>", I had the same error.

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android and iOS ports available for testing
« Reply #297 on: October 28, 2014, 06:57:42 am »
Hm, I wanted to write that I have all ok with sf::String, but I've found that I have no any code with using of sf::String(const char*) directly. It's because I'm using LanguageManager where all text is in external lang files and sf::String returned by function that converts UTF8 source text to std::string.

jd6

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Android and iOS ports available for testing
« Reply #298 on: October 28, 2014, 09:04:50 am »
Thanks for your answer ! :)

So I will continue to use wchar_t*.

Now, I will try debugging without Qt. I keep you informed.

jd6

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Android and iOS ports available for testing
« Reply #299 on: October 29, 2014, 11:25:31 am »
I tested without Qt. I used Eclipse and ndk-build. But, I always had the segfault :
(click to show/hide)

How can I resolve this error ? Thanks in advance for your answer ! :)

AndroidManifest.xml :
(click to show/hide)

MainActivity.java :
(click to show/hide)

sfmlexample.cpp :
(click to show/hide)

Android.mk :
(click to show/hide)

I tried to use ndk-gdb-py, but I had an error :
(click to show/hide)

 

anything