Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › How to include cpp- files into code on Android?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #15607

    Nin4ikP

    Hello,

     

    I have a little question, but cannot poste the whole code here. Hope, my description is enough..

    If I include my own class named “FileIO” in my .qml-files, I can use them properly. But if I start debugging on android, it doesn’t work anymore (red underlined and doesn’t read the txt file, like it’s supposed to). I import it like this:

    import FileIO 1.0

    Do you know, if I have to write something additional in the main probably or make some settings?

    Right not the line in main.cpp looks like that:

    qmlRegisterType<FileIO, 1>("FileIO", 1, 0, "FileIO");

     

    Thank you

    Nina

    #15609

    Günther
    Felgo Team

    Hi!

    The code you posted looks correct, are you sure that the class is really not available on Android?
    It is also possible that there’s an issue with File-Access – relative paths and device folder structure might require some additional handling, you can add some debug output to the log with QDebug to see whether your code is working.

    Best
    Günther

    #15631

    Nin4ikP

    Hello Günther,

     

    I think, you could be right with saying that it has to do something with relative paths. I would like to check it on Android, if all the data was transfered on to my mobile, but I cannot find the right file. It’s supposed to be in Android/data/ …. com.yourcompany.w …

    But I cannot find it in my subfolders 🙁 I just can see this piece of information if I search for the game-name. Do you know, where I can find all the data of my game?

     

    Thank You.

    Best, Nina

    #15633

    Günther
    Felgo Team

    Hi!

    You can have a look at the Android Application Package if your assets are correctly packed into the APK. You can find the APK in the build directory under <build-dir>/android-build/build/outputs/apk. The APK is a simple archive, so you can for example rename it to .zip and unpack the archive to view the contents.

    If you are using the Qt Resource System, your configured files in resources.qrc will be compiled along with the application (they are not visible in the archive then). The specified DEPLOYMENTFOLDERS in your *.pro configuration (e.g. your projects assets folder) should be copied to the assets folder within the APK.

    Other files that are not within a DEPLOYMENTFOLDER or specified in the resources.qrc are not part of the application package and thus not available on the Android device.

    Best,
    Günther

    #15638

    Nin4ikP

    Hello Günther,

     

    I found the problem now with your help, but cannot solve it. I unzipped the file like you said and found out, that the fileio.cpp and .h are missing in the filesystem. Normally it is parallel to the main.cpp and the subfolders qml and assets. In the build I only can see the two subfolders, but no fileio.cpp/.h and no main.cpp. Maybe I did something wrong? I really need the cpp files to work properly.. :/

     

    Thank you!

    Best, Nina

    PS: I would like to add a screenshot, but cannot find the file attachment button… drag and drop doesn’t work for me either 🙁

    #15650

    Alex
    Felgo Team

    Hi Nina,

    have you added the C++ files to your .pro file (using HEADERS and SOURCES)? This should be enough to deploy them along with your project.

    Cheers,
    Alex

    #15661

    Nin4ikP

    Hey Alex,

     

    Yes, they are in my .pro file. It must have to do something with the missing .cpp/.h file in the folder. I didn’t have the time this week to work on that, so no improvements on this issues were done. If I find a solution, I will poste it here.

     

    Best,

    Nina

    #15665

    Günther
    Felgo Team

    Hi Nina!

    You do not see the the cpp files in the build directory because they are directly compiled when you build the project. But there should be for example a main.o in your build directory, which is the object file of the compiled main.cpp. I’m pretty sure that all your cpp files are correctly compiled if you added them to the SOURCES/HEADERS in your *.pro file (they are also visible in the Project Explorer of Qt Creator then).

     

    Best,
    Günther

    #15720

    Nin4ikP

    Hello,

     

    I just checked the .pro file again and this is how it looks like (just important parts):

    SOURCES += main.cpp \
        fileio.cpp
    
    android {
        ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
        OTHER_FILES += android/AndroidManifest.xml
    }
    
    HEADERS += \
        fileio.h

    Am I right to assume, that the .pro file is correct?

     

    I just erased the android build form my pc and the app from my phone and reinstalled it, and now I found these warnings. That must be the problem then:

     

    Warning: QML import could not be resolved in any of the import paths: FileIO

    Warning: QML import could not be resolved in any of the import paths: QtQuick.Extras.Private.CppUtils

    Warning: QML import could not be resolved in any of the import paths: QtQuick.Extras.Private.CppUtils

     

    Google tells me, that somebody solved it by adding the ANDROID_PACKAGE_SRC_DIR to his .pro file, but as I can see, it is in my .pro file already..

    Other google results refer to QML-files, not to .cpp (or generally own programmed). Probably you already know thsi issue?

     

    Thank you for your help!
    Best, Nina

     

    EDIT:

    And yes, main.obj and fileio.obj are in the build directory (not in the apk-package).

    #15728

    Günther
    Felgo Team

    Hi, I followed up via email with some further suggestions – please have a look.

    Best,
    Günther

Viewing 10 posts - 1 through 10 (of 10 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded