Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Downloading data from Web URL (For Android)



  • Hello Qt Community,

    I'm very new to Qt's networking and I am trying to download data from a csv file from a web URL on the Android phone. I am using the filedownloader.h file from this link:

    https://wiki.qt.io/Download_Data_from_URL

    While the link talks about downloading an image, I figured it could also download numerical data as well. As a test run, I decided to try downloading an image first to see if it will simply do anything at all. In my main.cpp file, I have the following code:

    #include "filedownloader.h"   // From the Qt Website (https://wiki.qt.io/Download_Data_from_URL)
    
    int main(int argc, char *argv[])
    {
       QApplication a(argc, argv);
    
       // The main window of the phone
       QWidget* window = new QWidget;
    
       window->setBackgroundRole(QPalette::Dark);
    
       QUrl imageUrl("https://freepngimg.com/download/the_elder_scrolls/23365-4-the-elder-scrolls-v-skyrim-transparent-background.png");
       FileDownloader* m_pImgCtrl = new FileDownloader(imageUrl, window);
       QObject::connect(m_pImgCtrl, SIGNAL (downloaded()), window, SLOT (loadImage()));
    
       QPixmap buttonImage;     
       buttonImage.loadFromData(m_pImgCtrl->downloadedData());
    
       window->show();
       return a.exec();
    }
    

    However, I keep getting the following errors:

    "W System.err: java.lang.ClassNotFoundException: Didn't find class "org.qtproject.qt5.android.network.QtNetwork" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
    W System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    W System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    W System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    W System.err: at org.qtproject.qt5.android.QtNative.startQtApplication(Native Method)
    W System.err: at org.qtproject.qt5.android.QtNative$7.run(QtNative.java:611)
    W System.err: at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61)
    W System.err: at java.lang.Thread.run(Thread.java:761)"

    It appears I am missing a path but do I put that path on the android itself or is there a different problem entirely? If there is even a better and much simpler way to achieve my goal, please share!

    Thank you!



  • @Mathematician, I'm seeing the same thing as well (in fact, I just noticed it and searched online about it and found your post). My stack is:

    W System.err: java.lang.ClassNotFoundException: Didn't find class "org.qtproject.qt5.android.network.QtNetwork" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /product/lib64]]
    W System.err: 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
    W System.err: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    W System.err: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    W System.err: 	at org.qtproject.qt5.android.QtNative.startQtApplication(Native Method)
    W System.err: 	at org.qtproject.qt5.android.QtNative$7.run(QtNative.java:611)
    W System.err: 	at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61)
    W System.err: 	at java.lang.Thread.run(Thread.java:919)
    

    Other than this output things still appear to be working though. I'm on 5.15.1. I don't think it's anything you (or I) are doing wrong.

    Are things working for you despite this?



  • I tested my app in Qt 5.15.1 for the first time today, and get the same error as you mentioned. The network stuff I've tested so far seem to work despite this warning.

    I also see there is a bugreport for this: https://bugreports.qt.io/browse/QTBUG-87288


Log in to reply