Skip to content
QtWS25 Call for Papers
  • 0 Votes
    3 Posts
    50 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
    4 Posts
    522 Views
    JoeCFDJ

    @TheoSys said in Qt6.7 Android: On app start crash with missing Java function:

    monotonic_buffer_resource

    C++ std::pmr::monotonic_buffer_resource is not available for libQt6Core_arm64-v8a.so.
    https://en.cppreference.com/w/cpp/memory/monotonic_buffer_resource
    ldd /lib/arm64/libQt6Core_arm64-v8a.so to check its dependencies and add the miss lib to your build

  • 0 Votes
    2 Posts
    180 Views
    S

    @Sammasas
    I didn't find a universal way, but with an QJNIObject and objective c it works now. Java with JNiObject:

    package Klingelball; import android.content.Context; import android.content.res.Configuration; import android.util.DisplayMetrics; import android.view.WindowManager; public class AndroidSettings { public static float getFontScale(Context context) { //return getResources().getConfiguration().fontScale; Configuration configuration = context.getResources().getConfiguration(); // Get the font scale from the configuration float fontScale = configuration.fontScale; return fontScale; } }

    It's important that the file is under src/mypackage.

    .cpp file:

    #ifdef Q_OS_ANDROID QJniObject context = QNativeInterface::QAndroidApplication::context(); if(QJniObject::isClassAvailable("Klingelball/AndroidSettings")) { QJniObject androidSettingsJavaObject = QJniObject("Klingelball/AndroidSettings"); fontScale = new float(androidSettingsJavaObject.callStaticMethod<jfloat>("Klingelball/AndroidSettings", "getFontScale", "(Landroid/content/Context;)F", context.object<jobject>())); qDebug() <<"Font scale:" << *fontScale; setup_fontAndroid(*fontScale); } else { qDebug() << "JAVA CLASS UNAVAIABLE!"; fontScale = new float(1); setup_fontAndroid(*fontScale); } #endif

    iOs with objective-c:
    .mm file:

    include "iOSSettings.h" #include <UIKit/UIKit.h> int iOSSettings::getPrefferedFont() { return [UIFont preferredFontForTextStyle:UIFontTextStyleBody].pointSize; }

    .h file:

    class iOSSettings { public: static int getPrefferedFont(); };

    .cpp file:

    #ifdef Q_OS_IOS fontScale = new float(getfontScalefrompointSize(iOSSettings::getPrefferedFont())); setup_fontiOS(iOSSettings::getPrefferedFont()); #endif

    iOS returns the preffered Fontsize, I implemented a function that returns a factor based on the fontsize because I had to scale the Icons too.
    Hope this helps somebody :)

  • 1 Votes
    1 Posts
    200 Views
    No one has replied
  • 0 Votes
    4 Posts
    268 Views
    JoeCFDJ

    @chenPeng First, you need to click Download OpenSSL Button to install android_openssl.

  • 0 Votes
    9 Posts
    1k Views
    B

    I had the same problem and solved it on Ubuntu by deleting the cache of QtCreator using :

    rm -R ~/.cache/QtProject
  • 2 Votes
    8 Posts
    404 Views
    ekkescornerE

    @SGaist did some more tests. removed some lines with errors from .pro and got some more output from qmake2cmake. but only for the easy parts ;-)

    android or ios - specific parts are missed.
    ATM I'm learning from CMakeLists.txt provided by Qt example apps, other projects and documentation.

    what's really missed: official guides for mobile (android and ios) apps (including translations, native code, custom info.plist, Android Manifest, openSSL) from build to deploy and publish to stores using CMake.

    of course I'll blog about my findings in some weeks.

  • 1 Votes
    6 Posts
    1k Views
    JoeCFDJ

    @TheoSys File a bug to Qt and tell them to fix it.

  • 0 Votes
    2 Posts
    506 Views
    BondrusiekB

    @Bondrusiek
    I solved that. Do this steps:

    Select the "Projects" tab on the left. In the left side panel, select the "Build Android APK" section. Scroll down to the "Build Steps" section and find the "Packaging" step. In the "Packaging" section, you should see a "Sign package" checkbox. Make sure it's checked. Configure "Signing Configuration" with required information such as keystore file path, keystore password, key alias and key password. If you don't already have a keystore file, you can create one using the java keytool. Click the "Apply" button to save your changes. Now try building your Android APK again by clicking on the green arrow icon (or using Ctrl + B) in the lower left corner of Qt Creator.
  • 0 Votes
    3 Posts
    510 Views
    SeDiS

    @JoeCFD Thank you for your answer, but that was exactly what I had done - tried and tried all over again. The solution came now with vigorously erasing all of AndroidSDK, upgrading Creator. Now it works!! I'll probably never know why it didn't before. :-)

  • 2 Votes
    3 Posts
    400 Views
    A

    UPDATE: This is a known bug in Qt https://bugreports.qt.io/browse/QTBUG-113616

  • 0 Votes
    2 Posts
    268 Views
    TomZT

    I always sign all packages I deploy on the device, regardless of it being a debug or release one.

    Why would debug vs release make any difference in whether it should be signed or not?

  • 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!

  • 1 Votes
    1 Posts
    190 Views
    No one has replied
  • 0 Votes
    3 Posts
    987 Views
    V

    @TheoSys said in Qt6.5.0: Android: Can't create main activity:

    Qt5.15 app for Android to Qt6.5.0

    Exactly the same problem after moving app from Qt5.15 Qt6.5

  • 0 Votes
    1 Posts
    148 Views
    No one has replied
  • 0 Votes
    3 Posts
    311 Views
    A

    @JoeCFD
    thank you so much for your reply. you save me from this problem.
    i solve this by removing other mingW compiler and it work properly.

  • 0 Votes
    4 Posts
    395 Views
    A

    I figure out this is because of Q_Object macro I added in those files.
    I don't know why the macro doesn't work maybe better open another post.
    in other posts people suggest to rerun the qmke to solve this problem but doesn't work for me
    anyone know why Q_Object macro doesn't work for android?

  • 0 Votes
    1 Posts
    222 Views
    No one has replied
  • 0 Votes
    1 Posts
    189 Views
    No one has replied