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. Multidex support with Qt Android

Multidex support with Qt Android

Scheduled Pinned Locked Moved Mobile and Embedded
qtcoreandroidmultidex
2 Posts 2 Posters 2.0k 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.
  • robolivableR Offline
    robolivableR Offline
    robolivable
    wrote on last edited by
    #1

    Multidex support for Android looks to be like an unlit topic in the Qt community, so I thought I'd share my experiences in a topic post.

    When extending your Qt Android application with custom activities, you may want to take advantage of integrating external libraries. With the number of SDKs/plugins that are available, it can be easy to reach that 65K method limit. This is the issue that multidex support is meant to solve.

    Enabling multidex support on Qt isn't difficult, and can be achieved with the following steps (I'm including the steps required for the legacy multidex library, assuming that most Qt apps will have a minSdkVersion of lower than 20):

    1. Assuming you have already created your Android template files, add the following line to the project's "dependencies" block in your build.gradle file: compile 'com.android.support:multidex:1.0.0'

    2. In the same file, inside the "android" block, add the following: defaultConfig { multiDexEnabled = true }

    3. Add the following import to your application's main activity file: import android.support.multidex.MultiDex;

    4. The last step involves overriding the following method in your application's main activity class (the class that extends QtActivity):

       /* Multidex support */
       @Override
       protected void attachBaseContext(Context base) {
           super.attachBaseContext(base);
           MultiDex.install(this);
       }
      
    5. You're done, go ahead and build your application.

    This was the most common error I ran into:java.lang.ClassNotFoundException: Didn't find class "org.qtproject.qt5.android.QtActivityDelegate" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib]]. This happens when you don't integrate multidex correctly. Specifically, the ClassNotFoundException goes away after calling MultiDex.install() in your main activity class.

    Hope this ends up helping someone.

    1 Reply Last reply
    1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Thanks for sharing this ! Looks it might be worth including in Qt's platform notes for Android

      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

      • Login

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