How to build and run SDL application written in Qt for Android ?
-
Is there a way to run a SDL application for Android which is written in qt.
My application is a video call application which is implemented using Pjsip , OpenH264 Codec and SDL2..It Works great in Linux and windows , but not in Android.
I'm using PJSIP in my application where for example to make a video preview (Local video), video preview function (pjsua_vid_preview_start) is called from pjsip file (from the file pjsua.h) where pjsip internally calls a sdl function from the file sdl_dev.c which is in pjsip source folder.I'm not able to get the video or even preview the video,I thought it is because i'm not building SDL for android properly in qt and not linking sdl in Qt (I compiled SDL using ndk-build.
the error is like:
D/dalvikvm( 1431): No JNI_OnLoad found in /data/data/org.qtproject.example.testSdlQt/lib/libtestSdlQt.so 0x9f0113c8, skipping init
E/ ( 1431): dlsym failed: Symbol not found:
E/ ( 1431): Could not find main method
F/libc ( 1431): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 1450 (qtMainLoopThrea)
I/DEBUG ( 651): pid: 1431, tid: 1450, name: qtMainLoopThrea >>> org.qtproject.example.testSdlQt <<<
D/Zygote ( 654): Process 1431 terminated by signal (11)
I/ActivityManager( 837): Process org.qtproject.example.testSdlQt (pid 1431) has died.I'm been struck with this issue from past couple of months..can anyone guide me please...
Thanks in Advance. -
@nivedha_02 said in How to build and run SDL application written in Qt for Android ?:
I thought it is because i'm not building SDL for android properly
please show command you used to build the SDL library for Android
not linking sdl in Qt (
please show your .pro file and describe your subfolder structure for your Qt project.
-
@Pablo-J-Rogina said in How to build and run SDL application written in Qt for Android ?:
please show command you used to build the SDL library for Android
not linking sdl in Qt (
command used to build the SDL library for Android :
ndk-build APP_PLATFORM=android-16 NDK_TOOLCHAIN_VERSION=4.9(you can refer the link :
https://forum.qt.io/topic/121909/how-to-build-qt-sdl-application-in-android
here in this post i have described how i have followed to procedure for ndk-build).pro file :
QT += core gui androidextras
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = VideoConference
TEMPLATE = appCONFIG += c++11
SOURCES += main.cppINCLUDEPATH += $$PWD/pjproject-2.9
$$PWD/pjproject-2.9/pjsip/include
$$PWD/pjproject-2.9/pjlib/include
$$PWD/pjproject-2.9/pjlib-util/include
$$PWD/pjproject-2.9/pjmedia/include
$$PWD/pjproject-2.9/pjnath/includeINCLUDEPATH +=
pkg-config --cflags --libs /usr/local/lib/pkgconfig/libpjproject.pc
LIBS +=pkg-config --libs /usr/local/lib/pkgconfig/libpjproject.pc
*LIBS +=-L$$PWD/pjproject-2.9/pjsip/lib
-L$$PWD/pjproject-2.9/pjlib/lib
-L$$PWD/pjproject-2.9/pjlib-util/lib
-L$$PWD/pjproject-2.9/pjnath/lib
-L$$PWD/pjproject-2.9/pjmedia/lib
-L$$PWD/pjproject-2.9/third_party/lib *OTHER_FILES +=
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/pjproject-2.9/pjlib/lib/release/ -lpj-arm-unknown-linux-androideabi
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/pjproject-2.9/pjlib/lib/debug/ -lpj-arm-unknown-linux-androideabi
else:unix: LIBS += -L$$PWD/pjproject-2.9/pjlib/lib/ -lpj-arm-unknown-linux-androideabiINCLUDEPATH += $$PWD/pjproject-2.9/pjlib/include
DEPENDPATH += $$PWD/pjproject-2.9/pjlib/includewin32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/pjproject-2.9/pjlib/lib/release/libpj-arm-unknown-linux-androideabi.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/pjproject-2.9/pjlib/lib/debug/libpj-arm-unknown-linux-androideabi.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/pjproject-2.9/pjlib/lib/release/pj-arm-unknown-linux-androideabi.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/pjproject-2.9/pjlib/lib/debug/pj-arm-unknown-linux-androideabi.lib
else:unix: PRE_TARGETDEPS += $$PWD/pjproject-2.9/pjlib/lib/libpj-arm-unknown-linux-androideabi.a
.
.
. (pjsip external libraries)
.
.
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/pjproject-2.9/third_party/lib/release/ -lyuv-arm-unknown-linux-androideabi
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/pjproject-2.9/third_party/lib/debug/ -lyuv-arm-unknown-linux-androideabi
else:unix: LIBS += -L$$PWD/pjproject-2.9/third_party/lib/ -lyuv-arm-unknown-linux-androideabiINCLUDEPATH += $$PWD/pjproject-2.9/third_party
DEPENDPATH += $$PWD/pjproject-2.9/third_partywin32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/pjproject-2.9/third_party/lib/release/libyuv-arm-unknown-linux-androideabi.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/pjproject-2.9/third_party/lib/debug/libyuv-arm-unknown-linux-androideabi.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/pjproject-2.9/third_party/lib/release/yuv-arm-unknown-linux-androideabi.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/pjproject-2.9/third_party/lib/debug/yuv-arm-unknown-linux-androideabi.lib
else:unix: PRE_TARGETDEPS += $$PWD/pjproject-2.9/third_party/lib/libyuv-arm-unknown-linux-androideabi.acontains(ANDROID_TARGET_ARCH,armeabi-v7a) {
ANDROID_EXTRA_LIBS =
/root/Documents/test/../../../usr/local/lib/libopenh264.so
/root/Documents/test/../../../usr/local/lib/libSDL2.so *
$$PWD/../../../usr/local/lib/libmain.so
}FORMS +=
-
@Pablo-J-Rogina said in How to build and run SDL application written in Qt for Android ?:
describe your subfolder structure for your Qt project.
As i could'nt find a way to build my complete video call application , i extracted separately the video preview part and created a completely new project which has only video preview in it ,this preview video code was included in main.cpp itself., so now my subfolder structure of my Qt project is..
testPreview.pro & main.cpp (under Sources folder). -
@Pablo-J-Rogina :
here Im describing clearly what i have done:
Following are the steps i had followed to build apk of my video call application :-
QT version - 5.11.3 , ndk - 10e (GCC toolchain) (later used 20b for Qt version 5.14.0 clang toolchain) , SDK - 26.1.1 , JDK - 1.8 ,OpenH264 downloaded from github , sdl 2.0.8
-
I'm using OpenH264 as the codec , i had cross compiled openH264 for android using the command :
make OS=android NDKROOT=android-ndk-r10e TARGET=android-16 libopenh264.so APP_ABI=armeabi-v7a ARCH=arm NDKLEVEL=16
make OS=android NDKROOT=/root/android-ndk-r10e TARGET=android-16 libopenh264.so APP_ABI=armeabi-v7a ARCH=arm NDKLEVEL=16 clean
make install OS=android NDKROOT=/root/android-ndk-r10e TARGET=android-16 libopenh264.so APP_ABI=armeabi-v7a ARCH=arm NDKLEVEL=16
- I had complied SDL for android following the README-android file found in SDL source folder ie.,
(Not sure of how to build sdl for android)
- Downloaded SDL2 source code and extract 'android-project' folder from it and renamed it to the name of my project.
- Created a symbolic link of SDL2 source code as ./SDL inside 'app' folder.
- Modified 'Android.mk' with the name of the source file in 'LOCAL_SRC_FILES' and set CFLAGS and included few files in INCLUDEPATH.
- Ran ndk-build from jni > src folder and on successful build libsdl.so and libmain.so got generated.
- Compiled pjsip with openH264 and sdl2 :
TARGET_ABI=armeabi-v7a APP_PLATFORM=android-16 ./configure-android --use-ndk-cflags --with-openh264=/usr/local --with-sdl
followed by make & make install.
-
Included these .so files in qt pro file under 'ANDROID_EXTRA_LIBS'.
-
clean , qmake , build was successful.
-
On Running the application in Qt , following error was displayed and the application got crashed (testSdlQt - is the name of the project):
D/dalvikvm( 1431): No JNI_OnLoad found in /data/data/org.qtproject.example.testSdlQt lib/libtestSdlQt.so 0x9f0113c8, skipping init
E/ ( 1431): dlsym failed: Symbol not found:
E/ ( 1431): Could not find main method
F/libc ( 1431): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 1450 (qtMainLoopThrea)
I/DEBUG ( 651): pid: 1431, tid: 1450, name: qtMainLoopThrea >>> org.qtproject.example.testSdlQt <<<
D/Zygote ( 654): Process 1431 terminated by signal (11)
I/ActivityManager( 837): Process org.qtproject.example.testSdlQt (pid 1431) has died.Although apk was generated , when i run it the application crashes saying ('Application Stopped unexpectedly').
Can Anyone help me how to proceed or Guide me how to build my video call application in Android which was developed in Qt using pjsip libraries , sdl (pjsip internally calls SDL functions hence sdl comes in to picture) , openH264 .
-
-
@nivedha_02 :
Was this issue resolved?