Skip to content
  • 0 Votes
    3 Posts
    462 Views
    D

    @gregory109 I tried:

    QtJniTypes::Context context = QNativeInterface::QAndroidApplication::context(); m_javaObject = QJniObject("org/qtproject/qt/android/purchasing/InAppPurchase", "(Landroid/content/Context;J)V", context, this);

    but it did not help. Looks like QtJniTypes::Context is not a trivial type defined with Q_DECLARE_JNI_CLASS(Context, "android/content/Context").

  • 0 Votes
    8 Posts
    1k Views
    R

    @Recursion

    I really think I identified the actual issue now so I need help essentially getting my Xamarin service added/linked to the Qt project. I am unsure how to do this.

    I followed the tutorial here and I have tried both starting up the function in the service and binding to it and neither work.

    QT6 Android Services

    I am pretty convinced that the problem is that in the example they created a class QtAndroidService that extends QtService. In my case I just extended Service as QtService isn't available in Xamarin/C#. The example says this should work.

    Here is the thing though. In the example it executes the function for example bycalling the method startQtAndroidService located at "org/qtproject/example/qtandroidservice/QtAndroidService".

    I looked at my current Qt project and its directory starts off the exact same "org.qtproject.example.myappname". I guess I must have just built the UI off an example and never changed it.

    So I think this means that somehow they put the library file QtAndroidService within the Qt project.

    I'm assuming its a .so file because when I currently run it I'll get back an error saying "Didn't find class "SOB.Bacon.com.backend.RunBackend.ForegroundBackendService" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /system/vendor/lib]]". The class is still named ForegroundBackendService but its not a foreground service anymore I followed the example exactly just kept the same name I'll change it.

    If I look in the /system/lib folder on the Android device it is filled with files with lib in the name ending in .so.

    If I look in my SOB.Bacon project install directory on the Android device there is a lib folder. I do not see a library with the same name as my service though, the .so files that are in there seem to have nothing to do with anything other than what Xamarin needs.

    So first off I do not know how to get Xamarin to generate a .so file. It will make a .dll file but that is for use by other Xamarin applications.

    So I have two routes/questions:

    1. Based on that example how do I link/point Qt to look for the service in a different location on the Android tablet, right now it seems to only be looking in /system/lib or /system/vendor/lib.

    2. If a .so file is required, how was the other xamarin application able to execute the service, and how was ADB able to execute the service? In which case how do I make Qt execute a service that is NOT part of its own package?

    Thanks a lot!

  • 0 Votes
    9 Posts
    1k Views
    K

    After spending more hours to exploring the new Window API on SDK >= 30 I have conclusion with this new Window API. The WindowInsets did not separate from DecorView, but this WindowInsets is inherited from DecorView, so you must calling DecorView first. Thanks for yours helps especially @JoeCFD for remembering me to write the correct return type. Here I gave pieces codes to facing the new Android API as Holiday gift 2022 pieces codes to facing new Android API SDK >= 30

  • 0 Votes
    2 Posts
    636 Views
    advmA

    I don't understand this well:

    From looking at the documentation, it seems that the QAndroidJniObject constructor and methods have to be attaching and detaching the current thread to and from the JVM, which isn't going to work in a JNI thread that's already attached to the JVM.

    Does this mean that, if I call C++ function(that uses QAndroidJniObject) from java JNI class, it is not going to work?
    Because as I understand, QAndroidJniObject is attaching and detaching the current thread to and from the JVM, and the JNI java object that is calling native functions, is already attached to the JVM.
    Please correct me if I am wrong.

  • 0 Votes
    3 Posts
    544 Views
    KroMignonK

    @Dmitriano I guess QAndroidJniEnvironment::ExceptionCheck() purpose is to catch exception which occurred during function execution and not "function not exist" exception. So your use case is not covered.

    Don't you have hand over Java code? Just create an empty function which throw an exception, this should be catchable with QAndroidJniEnvironment::ExceptionCheck().

  • 0 Votes
    2 Posts
    848 Views
    raven-worxR

    @Qjay said in QtAndroid local notifications , notifications poping up immediately:

    the notifications are popping up almost instantly ( despite me providing time for it ).

    you pass the time you want it to be triggered from now on. The API expects a time since EPOCH (as your comment in the code also states) which are the milliseconds from 1970/01/01 on.
    So in your JAVA code add new Date().getTime() milliseconds to your current timeout.

    So far i am able to get the notifications ( but not on Android O )

    did you read this already?
    Alos chekc the Qt debugger console and/or LogCat for suspicious messages regarding notifications.

  • 0 Votes
    3 Posts
    2k Views
    ekkescornerE

    @Kyrw thx. already found this out but forgot to mention here and to close the thread.

  • 0 Votes
    1 Posts
    802 Views
    No one has replied
  • 0 Votes
    2 Posts
    1k Views
    SGaistS

    Hi,

    This article is likely what you are looking for.

    Hope it helps

  • 0 Votes
    3 Posts
    1k Views
    N

    Thank you, with the StandardPaths's its working with QSqlDatabase.
    But does anybody know how to solve the above mentioned problem?

  • 0 Votes
    3 Posts
    2k Views
    L

    @benlau
    Thanks,
    it probably depend on QtActivity that set something as you said but can't find the solution...

  • 0 Votes
    1 Posts
    2k Views
    No one has replied
  • 0 Votes
    3 Posts
    3k Views
    benlauB

    The next version of QuickAndroid will come with a Image Picker using native code. You may use it directly or just check learn how its handle image picking. In fact, it is a bit troublesome to do it in Android. There has several way of passing image data. (e.g clip data, content url , file url). It depends on the photo application.

    quickandroid/ImagePicker.java at DEV · benlau/quickandroid

    quickandroid/ImagePicker.qml at DEV · benlau/quickandroid

    p.s Daily build of apk with image picker is available at :

    Downloads | quickandroid

  • 0 Votes
    2 Posts
    2k Views
    S

    @moozoom
    I run in the same paradigm when I try to create a static linked library with Qt targeting Android and latter to use it with JINI on Android Studio.
    Reading you post I see you have almost the same problem like me with one difference.
    To me are working as far I use only std library
    My problem appears when I use QString for example in the library.
    Looks the static build does not statically includes the Qt framework dependencies.
    Finally did you find a solution? Me I run with this issue past over one month.
    Thanks

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    1 Posts
    901 Views
    No one has replied
  • 0 Votes
    7 Posts
    3k Views
    A

    Hi, sorry for the delay!
    Here they are the first lines from the debugger:

    Starting remote process.I/art ( 2684): Late-enabling -Xcheck:jni I/LoadedApk( 2684): No resource references to update in package common I/LoadedApk( 2684): No resource references to update in package com.cyngn.hexo W/ResourceType( 2684): For resource 0x01030224, entry index(548) is beyond type entryCount(9) W/ResourceType( 2684): For resource 0x01030224, entry index(548) is beyond type entryCount(9) I/Qt ( 2684): qt start D/ ( 2684): (null):0 ((null)): QML debugging is enabled. Only use this in a safe environment. W/Qt A11Y ( 2684): Could not activate platform accessibility. D/OpenGLRenderer( 2684): Render dirty regions requested: true D/Atlas ( 2684): Validating map... I/Adreno-EGL( 2684): <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.1.C2.05.00.00.046.002_msm8974_LA.BF.1.1.1.C2__release_AU () I/Adreno-EGL( 2684): OpenGL ES Shader Compiler Version: E031.25.03.00 I/Adreno-EGL( 2684): Build Date: 01/06/15 Tue I/Adreno-EGL( 2684): Local Branch: mybranch6793908 I/Adreno-EGL( 2684): Remote Branch: quic/LA.BF.1.1.1.c2 I/Adreno-EGL( 2684): Local Patches: NONE I/Adreno-EGL( 2684): Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.1.C2.05.00.00.046.002 + NOTHING I/OpenGLRenderer( 2684): Initialized EGL, version 1.4 D/OpenGLRenderer( 2684): Enabling debug mode 0 D/libNFCtest.so( 2684): ../NFCtest/nfcintent.cpp:20 (void NFCIntent::init()): false I/Timeline( 2684): Timeline: Activity_idle id: android.os.BinderProxy@31a9db3f time:25527170 F/art ( 2684): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception 'java.lang.RuntimeException' thrown in unknown throw location F/art ( 2684): art/runtime/check_jni.cc:65] in call to NewGlobalRef F/art ( 2684): art/runtime/check_jni.cc:65] "QtThread" prio=5 tid=15 Runnable F/art ( 2684): art/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x12d2f0e0 self=0xa172f400 F/art ( 2684): art/runtime/check_jni.cc:65] | sysTid=2704 nice=0 cgrp=apps sched=0/0 handle=0xa24ed480 F/art ( 2684): art/runtime/check_jni.cc:65] | state=R schedstat=( 46736358 42323642 107 ) utm=4 stm=0 core=0 HZ=100 F/art ( 2684): art/runtime/check_jni.cc:65] | stack=0xa1b55000-0xa1b57000 stackSize=1012KB F/art ( 2684): art/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held) F/art ( 2684): art/runtime/check_jni.cc:65] native: #00 pc 00004640 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23) F/art ( 2684): art/runtime/check_jni.cc:65] native: #01 pc 00002e8d /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8) F/art ( 2684): art/runtime/check_jni.cc:65] native: #02 pc 0023ee95 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+68) F/art ( 2684): art/runtime/check_jni.cc:65] native: #03 pc 0022432f /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+146) F/art ( 2684): art/runtime/check_jni.cc:65] native: #04 pc 000af913 /system/lib/libart.so (art::JniAbort(char const*, char const*)+582) F/art ( 2684): art/runtime/check_jni.cc:65] native: #05 pc 000b004d /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+60) F/art ( 2684): art/runtime/check_jni.cc:65] native: #06 pc 000b315d /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*, int, char const*)+1284) F/art ( 2684): art/runtime/check_jni.cc:65] native: #07 pc 000b43c5 /system/lib/libart.so (art::CheckJNI::NewGlobalRef(_JNIEnv*, _jobject*)+20) F/art ( 2684): art/runtime/check_jni.cc:65] native: #08 pc 001b38ff /data/app/org.qtproject.nfc-2/lib/arm/libQt5Core.so (QJNIObjectPrivate::QJNIObjectPrivate(_jobject*)+82) F/art ( 2684): art/runtime/check_jni.cc:65] native: #09 pc 001b3ef5 /data/app/org.qtproject.nfc-2/lib/arm/libQt5Core.so (???) F/art ( 2684): art/runtime/check_jni.cc:65] native: #10 pc 001b5fb1 /data/app/org.qtproject.nfc-2/lib/arm/libQt5Core.so (QJNIObjectPrivate::getStaticObjectField(char const*, char const*, char const*)+48) F/art ( 2684): art/runtime/check_jni.cc:65] native: #11 pc 000194d1 /data/data/org.qtproject.nfc/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???) F/art ( 2684): art/runtime/check_jni.cc:65] native: #12 pc 0001ce53 /data/data/org.qtproject.nfc/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???) F/art ( 2684): art/runtime/check_jni.cc:65] native: #13 pc 000bfc55 /data/app/org.qtproject.nfc-2/lib/arm/libQt5Quick.so (QSGRenderLoop::instance()+76) F/art ( 2684): art/runtime/check_jni.cc:65] native: #14 pc 000d6343 /data/app/org.qtproject.nfc-2/lib/arm/libQt5Quick.so (QQuickWindowPrivate::init(QQuickWindow*, QQuickRenderControl*)+162) F/art ( 2684): art/runtime/check_jni.cc:65] native: #15 pc 000d6523 /data/app/org.qtproject.nfc-2/lib/arm/libQt5Quick.so (QQuickWindow::QQuickWindow(QQuickWindowPrivate&, QWindow*)+30) F/art ( 2684): art/runtime/check_jni.cc:65] native: #16 pc 00136023 /data/app/org.qtproject.nfc-2/lib/arm/libQt5Quick.so (QQuickWindowQmlImpl::QQuickWindowQmlImpl(QWindow*)+66) F/art ( 2684): art/runtime/check_jni.cc:65] native: #17 pc 00136115 /data/app/org.qtproject.nfc-2/lib/arm/libQt5Quick.so (???) F/art ( 2684): art/runtime/check_jni.cc:65] native: #18 pc 00123c39 /data/app/org.qtproject.nfc-2/lib/arm/libQt5Qml.so (QQmlType::create() const+34) F/art ( 2684): art/runtime/check_jni.cc:65] native: #19 pc 0014b407 /data/app/org.qtproject.nfc-2/lib/arm/libQt5Qml.so (???) F/art ( 2684): art/runtime/check_jni.cc:65] native: #20 pc 0014bbfb /data/app/org.qtproject.nfc-2/lib/arm/libQt5Qml.so (???) F/art ( 2684): art/runtime/check_jni.cc:65] native: #21 pc 0011b657 /data/app/org.qtproject.nfc-2/lib/arm/libQt5Qml.so (QQmlComponentPrivate::beginCreate(QQmlContextData*)+342) F/art ( 2684): art/runtime/check_jni.cc:65] native: #22 pc 0011a29d /data/app/org.qtproject.nfc-2/lib/arm/libQt5Qml.so (QQmlComponent::create(QQmlContext*)+56) F/art ( 2684): art/runtime/check_jni.cc:65] native: #23 pc 001458eb /data/app/org.qtproject.nfc-2/lib/arm/libQt5Qml.so (QQmlApplicationEnginePrivate::_q_finishLoad(QObject*)+194) F/art ( 2684): art/runtime/check_jni.cc:65] native: #24 pc 00145e97 /data/app/org.qtproject.nfc-2/lib/arm/libQt5Qml.so (QQmlApplicationEnginePrivate::startLoad(QUrl const&, QByteArray const&, bool)+74) F/art ( 2684): art/runtime/check_jni.cc:65] native: #25 pc 00145eed /data/app/org.qtproject.nfc-2/lib/arm/libQt5Qml.so (QQmlApplicationEngine::load(QUrl const&)+20) F/art ( 2684): art/runtime/check_jni.cc:65] native: #26 pc 00001a50 /data/app/org.qtproject.nfc-2/lib/arm/libNFCtest.so (main+156) F/art ( 2684): art/runtime/check_jni.cc:65] native: #27 pc 00019a79 /data/data/org.qtproject.nfc/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???) F/art ( 2684): art/runtime/check_jni.cc:65] native: #28 pc 00013a1b /system/lib/libc.so (__pthread_start(void*)+30) F/art ( 2684): art/runtime/check_jni.cc:65] native: #29 pc 00011a0f /system/lib/libc.so (__start_thread+6) F/art ( 2684): art/runtime/check_jni.cc:65] (no managed stack frames) F/art ( 2684): art/runtime/check_jni.cc:65] F/art ( 2684): art/runtime/runtime.cc:284] Runtime aborting...

    I'm not sure why Qt if complaining with this: JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception 'java.lang.RuntimeException' thrown in unknown throw location.

    Maybe I'm not creating the JNI object as it should. Here is my code:

    main.cpp

    int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; NFCIntent mynfc; mynfc.init(); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec();

    }
    init function

    void NFCIntent::init() { QAndroidJniObject* nfc = new QAndroidJniObject("org/atron/nfc/MainActivity"); qDebug() << nfc->isValid(); }