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

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.2k 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.
  • R Offline
    R Offline
    Rajeshkannan
    wrote on 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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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

        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 last edited by Rajeshkannan
        #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

        SGaistS 1 Reply Last reply
        0
        • R Rajeshkannan

          @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

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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
          1
          • SGaistS SGaist

            @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 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

            SGaistS 1 Reply Last reply
            1
            • R Rajeshkannan

              @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

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on 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
              0
              • SGaistS SGaist

                @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 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

                • Login

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