Using QtAndroidBridge

107 views
Skip to first unread message

İsmail Dönmez

unread,
Feb 3, 2011, 11:00:02 AM2/3/11
to andro...@googlegroups.com
Hi all;

I am trying to use QtAndroidBridge but QtAndroidBridge::javaVM() always returns NULL, do I have to do something before calling that function?

Regards,
ismail

İsmail Dönmez

unread,
Feb 4, 2011, 3:25:23 AM2/4/11
to andro...@googlegroups.com
Ah looks like BogDan disabled QtAndroidBridge;

commit 696253a4b39e80786bbdb4bb4f3d6391b472804d
Author: BogDan Vatra <bog_d...@yahoo.com>
Date:   Tue Dec 28 02:56:40 2010 +0800

    Fix compilation with "-reduce-relocations -reduce-exports"
    
    Remove QtAndroidBridge dependencies. QtAndroidBridge needs to be rewriten,
    I'll disable it for now.
    Fix a lot of BogDan is an idiot bugs (only sw plugin is fixed).


This is very bad, is there a remedy for this? I need to call some Java functions from C++ side.

Regards,
ismail

провод

unread,
Feb 4, 2011, 4:40:24 AM2/4/11
to andro...@googlegroups.com
You could add a simple exported function in androidjnimain.cpp to
return a pointer to a JavaVM variable (m_javaVM), as Sergey and I did
in our branch months ago.
You also should be careful about reattaching your thread every time
you need to call a Java method -- BogDan's plugin, as far as I
remember, liked to detach the main() thread on every Qt to Java call.

2011/2/4 İsmail Dönmez <ism...@namtrac.org>:

İsmail Dönmez

unread,
Feb 4, 2011, 4:41:44 AM2/4/11
to andro...@googlegroups.com
Hmmm that makes sense, I'll try that. Thanks!

Regards,
ismail

BogDan

unread,
Feb 6, 2011, 10:22:34 PM2/6/11
to android-qt
Hi,

That is a bad idea, libQtAndroid_xx are PLUGINS, not libraries.
Currently they are loaded as libraries because I need to set some c++
<=> java connections, but is possible that in the future that this
plugins will be loaded directly by your application (QtCore module) as
plugins. If you are using them as libraries and more your application
require them to run, you'll have big problems.

Cheers,
BogDan.

On Feb 4, 9:40 am, провод <marf...@gmail.com> wrote:
> You could add a simple exported function in androidjnimain.cpp to
> return a pointer to a JavaVM variable (m_javaVM), as Sergey and I did
> in our branch months ago.
> You also should be careful about reattaching your thread every time
> you need to call a Java method -- BogDan's plugin, as far as I
> remember, liked to detach the main() thread on every Qt to Java call.
>
> 2011/2/4 İsmail Dönmez <ism...@namtrac.org>:
>
>
>
>
>
>
>
> > Ah looks like BogDan disabled QtAndroidBridge;
> > commit 696253a4b39e80786bbdb4bb4f3d6391b472804d
> > Author: BogDan Vatra <bog_dan...@yahoo.com>

BogDan

unread,
Feb 6, 2011, 10:25:31 PM2/6/11
to android-qt
Hi İsmail,

I disabled that library because it was a required library. I'm not
against of having an android specific library, I'm against to make
that library a required library for all apps.

For you, I see the following choices :
- export JavaVM and JNIEnv from qtmain_android.cpp (check QT_DIR/src/
android/cpp/). This file is compiled into your android application,
and you can do anything you want with it.
- create your own library, and be sure you export "jint JNICALL
JNI_OnLoad(JavaVM* vm, void* /*reserved*/) " method.
- create a good for all library, but be aware, you MUST maintain that
library for years, and you MUST be sure you NEVER break the API/ABI,
one mistake and all apps which are using it will stop working.

Cheers,
BogDan.

On Feb 4, 8:25 am, İsmail Dönmez <ism...@namtrac.org> wrote:
> Ah looks like BogDan disabled QtAndroidBridge;
>
> commit 696253a4b39e80786bbdb4bb4f3d6391b472804d
> Author: BogDan Vatra <bog_dan...@yahoo.com>

İsmail Dönmez

unread,
Feb 7, 2011, 6:21:50 AM2/7/11
to andro...@googlegroups.com
This worked fine, thanks!

ismail

Josua Dietze

unread,
Apr 10, 2011, 8:02:58 AM4/10/11
to andro...@googlegroups.com
Am 07.02.2011 04:25, schrieb BogDan:
> For you, I see the following choices :
> - export JavaVM and JNIEnv from qtmain_android.cpp (check QT_DIR/src/
> android/cpp/). This file is compiled into your android application,
> and you can do anything you want with it.

Forgive my noobness, but what would "exporting" mean specifically in this case?

I'm just scratching my head over the same issue (calling Java from native Qt),
and experimenting with a global "m_javaVM" got me nowhere - plus it's not
recommended as I have learned.

Thanks,
Josh

Reply all
Reply to author
Forward
0 new messages