Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. unable to add the html file into the android asset during compilation on Andriod
Servers for Qt installer are currently down

unable to add the html file into the android asset during compilation on Andriod

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 2 Posters 1.3k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    Rajeshkannan
    wrote on 6 Feb 2024, 18:35 last edited by
    #1

    i have tried by adding the following lines in my .pro file .Also i have kept the index.html in the root folder as main.qml file. Also added the index.html into the resource file by right clicking the qml.qrc and added it using the open in editor option.

    RESOURCES += qml.qrc
    
    deployment.files += /index.html
    deployment.path = /assets
    INSTALLS += deployment
    

    in the main.qml file i have used the below code .

      WebView {
                    id: webView
                    anchors.fill: parent
                    anchors.margins: 5
                    url:"file:///android_asset/index.html"
                    onLoadingChanged: {
                        if (loadRequest.errorString)
                            { console.error(loadRequest.errorString); }
                    }
                }
    
    

    i manually checked the build folder , the index.html file did not get added to this location "build-webviewonandroid-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug/android-build/assets$ "

    Also the code got compiled and iam able to deploy to a physical device . only getting the following error : E libwebviewonandroid.so: qml: net::ERR_FILE_NOT_FOUND

    R 1 Reply Last reply 7 Feb 2024, 08:03
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Feb 2024, 19:54 last edited by
      #2

      Hi,

      Intuitively: deployment.files += /index.html looks wrong. You are stating the index.html is at the root of your filesystem.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • R Rajeshkannan
        6 Feb 2024, 18:35

        i have tried by adding the following lines in my .pro file .Also i have kept the index.html in the root folder as main.qml file. Also added the index.html into the resource file by right clicking the qml.qrc and added it using the open in editor option.

        RESOURCES += qml.qrc
        
        deployment.files += /index.html
        deployment.path = /assets
        INSTALLS += deployment
        

        in the main.qml file i have used the below code .

          WebView {
                        id: webView
                        anchors.fill: parent
                        anchors.margins: 5
                        url:"file:///android_asset/index.html"
                        onLoadingChanged: {
                            if (loadRequest.errorString)
                                { console.error(loadRequest.errorString); }
                        }
                    }
        
        

        i manually checked the build folder , the index.html file did not get added to this location "build-webviewonandroid-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug/android-build/assets$ "

        Also the code got compiled and iam able to deploy to a physical device . only getting the following error : E libwebviewonandroid.so: qml: net::ERR_FILE_NOT_FOUND

        R Offline
        R Offline
        Rajeshkannan
        wrote on 7 Feb 2024, 08:03 last edited by Rajeshkannan 2 Jul 2024, 08:06
        #3

        @Rajeshkannan ..I have kept this index.html file in the same location as main.qml...both are at root folder. My understanding was during the build process this index .html gets automatically copied into the android's asset folder

        S 1 Reply Last reply 7 Feb 2024, 20:01
        0
        • R Rajeshkannan
          7 Feb 2024, 08:03

          @Rajeshkannan ..I have kept this index.html file in the same location as main.qml...both are at root folder. My understanding was during the build process this index .html gets automatically copied into the android's asset folder

          S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 7 Feb 2024, 20:01 last edited by
          #4

          @Rajeshkannan in the line deployment.files += you have to give the path to the actual file within your project.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          R 1 Reply Last reply 12 Feb 2024, 20:01
          1
          • S SGaist
            7 Feb 2024, 20:01

            @Rajeshkannan in the line deployment.files += you have to give the path to the actual file within your project.

            R Offline
            R Offline
            Rajeshkannan
            wrote on 12 Feb 2024, 20:01 last edited by
            #5

            @SGaist

            hi ,

            Below are the steps i did in ubuntu , to add the assets for android and it worked. Thank you!!!

            Step 1: Create a folder called android_asset in the root directory where you have the main.qml then add all the index.html files into it.

            Step 2: Right click the Rootfolder and add the android_asset folder by choosing the "Add Existing Directory".

            Step 3: paste the following in the .pro file

            deployment.files += android_asset/index.html
            deployment.path = /assets
            INSTALLS += deployment

            I compiled and run ..it worked

            S 1 Reply Last reply 12 Feb 2024, 20:07
            1
            • R Rajeshkannan
              12 Feb 2024, 20:01

              @SGaist

              hi ,

              Below are the steps i did in ubuntu , to add the assets for android and it worked. Thank you!!!

              Step 1: Create a folder called android_asset in the root directory where you have the main.qml then add all the index.html files into it.

              Step 2: Right click the Rootfolder and add the android_asset folder by choosing the "Add Existing Directory".

              Step 3: paste the following in the .pro file

              deployment.files += android_asset/index.html
              deployment.path = /assets
              INSTALLS += deployment

              I compiled and run ..it worked

              S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 12 Feb 2024, 20:07 last edited by
              #6

              @Rajeshkannan you're welcome !

              Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so other forum users may know a solution has been found :-)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              R 1 Reply Last reply 14 Feb 2024, 06:12
              0
              • S SGaist
                12 Feb 2024, 20:07

                @Rajeshkannan you're welcome !

                Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so other forum users may know a solution has been found :-)

                R Offline
                R Offline
                Rajeshkannan
                wrote on 14 Feb 2024, 06:12 last edited by
                #7

                @SGaist ,
                Just an additional note,

                in the main.qml we need to use like below:
                WebView {
                id: webView
                anchors.fill: parent
                anchors.margins: 5
                url:"file:///android_asset/index.html"
                onLoadingChanged: {
                if (loadRequest.errorString)
                { console.error(loadRequest.errorString); }
                }

                            WebChannel {
                                id: channel
                                registeredObjects: [someObject]
                            }
                        }
                
                1 Reply Last reply
                0
                • R Rajeshkannan has marked this topic as solved on 14 Feb 2024, 06:13

                1/7

                6 Feb 2024, 18:35

                • Login

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