Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. No qDebug()<<"Output"; on android
Forum Updated to NodeBB v4.3 + New Features

No qDebug()<<"Output"; on android

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 2 Posters 457 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SeDi
    wrote on 20 Jul 2024, 18:33 last edited by SeDi
    #1

    ...........
    Update: this problem might very well be linked to that pointed out here: https://forum.qt.io/topic/157825/waiting-for-the-debugger-to-attach
    ...........
    Writing for Android I don't see any qDebug()<<"Output"; whatsoever. Only after I've ended the program (e.g. from the phone by its back button), I see:

    15:05:59: 
    
    "org.qtproject.example.myTestProject" died.
    

    The problem occurs in new projects and across different Qt Versions.
    .........
    Update: It does, although, not appear on another person's Android device (Samsung Tablet SM-T830 with Android 10).
    .........
    I don't see anything in "Application Output" pane (except the above, after program ends).

    Debug output when running on Windows is fine, however. There everything works like expected.

    The code I use is simply:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
    // [automatically generated QML stuff omitted here] 
        engine.load(url);
        for (int i=0; i<100;i++) qDebug()<<"###############################!!!!!!!!!!!!!###############";
        // for (int i=0; i<100;i++) std::printf("###############################!!!!!!!!!!!!!###############");
        return app.exec();
    }
    

    I've tried:

    • making sure I use DEBUG configuration^^
    • restarting Windows machine and phone
    • adding android:debuggable="true" to <application...> tag in AndroidManifext.xml
    • toggling Edit|Preferences|Debugger|General|Force Logging To Console
    • toggling Edit|Preferences|Build&Run|Application Output|Merge stderr and stdout
    • starting new projects in different Qt Versions: 5.15.2, 6.5.1 and 6.7.2, with compat option(qmake) and without(cmake)
    • using std::fprintf(stderr, "output");
    • using std::cerr << QString("Output").toStdString() << std::endl;
    • setting qputenv("QT_ASSUME_STDERR_HAS_CONSOLE", "1");
    • uninstalling app before deploying again
    • removing build folders

    In the the (otherwise very vivid and cluttered) adb logcat the output does appear as

    07-20 14:26:46.551 17346 17367 D libtestLogCompat_arm64-v8a.so: ###############################!!!!!!!!!!!!!###############
    07-20 14:26:46.552 17346 17367 I chatty  : uid=10169(org.qtproject.example.testLogCompat) qtMainLoopThrea identical 98 lines
    07-20 14:26:46.552 17346 17367 D libtestLogCompat_arm64-v8a.so: ###############################!!!!!!!!!!!!!###############
    

    Would be fine - but it's buried under thousands of other log lines.

    The same applies for console.log("output") from QML
    N.B.: I couldn't find output to std::printf anywhere.

    Win 10 machine, Qt Creator 13.0.2, deploying to a Nokia 8 (TA-1012) with Android 9, several Qt versions.

    1 Reply Last reply
    0
    • S SeDi marked this topic as a regular topic on 20 Jul 2024, 19:03
    • S SeDi referenced this topic on 21 Jul 2024, 11:48
    • M Offline
      M Offline
      maris
      wrote on 23 Jul 2024, 12:31 last edited by
      #2

      I don't understand why but qWarning() works OK ;)

      other solution, use spdlog

      #include "spdlog/sinks/android_sink.h"
      
          // auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/multisink.txt", true);
          // file_sink->set_level(spdlog::level::trace);
          auto android_sink = std::make_shared<spdlog::sinks::android_sink_mt>("ssss", false);
          android_sink->set_pattern("[multi_sink_example] [%^%l%$] %v"); // to dziala jak jest "false" powyżej
      
          spdlog::set_default_logger(std::make_shared<spdlog::logger>("multi_sink",
              spdlog::sinks_init_list({android_sink
                                      // ,file_sink
                                      }))
          );
      
       spdlog::info("###############################!!!!!!!!!!!!!###############");
      
      1 Reply Last reply
      0

      1/2

      20 Jul 2024, 18:33

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved