title: Android App needs com/sun/jna/android-aarch64/libjnidispatch.so | Javacv | libffm
body: <p>I try to implement an App which is using the JavaCV implementation. The gradle file looks like this</p>
  <pre><code>apply plugin: 'com.android.application'
  
  def AAVersion = '4.8.0'
  def acraVersion = '5.7.0'
  
  android {
      compileSdkVersion 31
  
      defaultConfig {
          configurations.all {
              resolutionStrategy { force 'androidx.core:core:1.6.0' }
          }
          applicationId &quot;de.mw.talk2drone&quot;
          minSdkVersion 31
          targetSdkVersion 31
          versionCode 1
          versionName &quot;1.0&quot;
          ndk {
              abiFilters 'arm64-v8a'
          }
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
          javaCompileOptions {
              annotationProcessorOptions {
                  arguments = [
                          &quot;androidManifestFile&quot;: &quot;$projectDir/src/main/AndroidManifest.xml&quot;.toString(),
                          &quot;resourcePackageName&quot;: android.defaultConfig.applicationId
                  ]
              } // annotationProcessorOptions
          } // javaCompileOptions
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
      lintOptions {
          checkReleaseBuilds true // Add this
          abortOnError false
      }
  
      sourceSets {
          main {
              manifest.srcFile 'src/main/AndroidManifest.xml'
              java.srcDirs = ['src/main/java', 'build/generated/source/apt/${variant.dirName}']
              resources.srcDirs = ['src/main/res']
              res.srcDirs = ['src/main/res']
              assets.srcDirs = ['src/main/assets']
          }
      }
  
      packagingOptions {
          exclude 'META-INF/native-image/ios**'
          exclude 'META-INF/native-image/linux**'
          exclude 'META-INF/native-image/windows**'
          exclude 'META-INF/native-image/android**'
          exclude 'META-INF/native-image/macosx**'
  
      }
      dependenciesInfo {
          includeInApk false
          includeInBundle false
      }
  }
  
  configurations {
      javacpp
  }
  
  task javacppExtract(type: Copy) {
      dependsOn configurations.javacpp
  
      from { configurations.javacpp.collect { zipTree(it) } }
      include &quot;lib/**&quot;
      into &quot;$buildDir/javacpp/&quot;
      android.sourceSets.main.jniLibs.srcDirs += [&quot;$buildDir/javacpp/lib/&quot;]
  
      tasks.getByName('preBuild').dependsOn javacppExtract
  }
  
  dependencies {
      implementation 'net.java.dev.jna:jna:5.10.0'
      implementation 'androidx.appcompat:appcompat:1.4.1'
  
      implementation group: 'com.alphacephei', name: 'vosk-android', version: '0.3.34'
      implementation project(':models')
      implementation 'com.google.android.material:material:1.5.0'
      implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
      implementation 'androidx.navigation:navigation-fragment:2.3.5'
      implementation 'androidx.navigation:navigation-ui:2.3.5'
      implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
      implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
      implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
      // To use constraintlayout in compose
      implementation 'androidx.constraintlayout:constraintlayout-compose:1.0.0'
      implementation &quot;ch.acra:acra-mail:$acraVersion&quot;
      implementation &quot;ch.acra:acra-toast:$acraVersion&quot;
      implementation &quot;ch.acra:acra-core:$acraVersion&quot;
      implementation &quot;androidx.preference:preference:1.1.1&quot;
  
      implementation &quot;org.androidannotations:androidannotations-api:$AAVersion&quot;
      implementation 'androidx.legacy:legacy-support-v4:1.0.0'
      annotationProcessor &quot;org.androidannotations:androidannotations:$AAVersion&quot;
      annotationProcessor 'com.google.dagger:dagger-compiler:2.40.5'
  
      testImplementation 'junit:junit:4.13.2'
      androidTestImplementation 'androidx.test.ext:junit:1.1.3'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
      implementation 'org.json:json:20211205'
  
      implementation group: 'org.bytedeco', name: 'javacv', version: '1.5.6'
      javacpp group: 'org.bytedeco', name: 'opencv-platform', version: '4.5.3-1.5.6'
      javacpp group: 'org.bytedeco', name: 'ffmpeg-platform', version: '4.4-1.5.6'
      //implementation group: 'org.bytedeco', name: 'opencv-platform', version: '4.5.3-1.5.6'
      //implementation group: 'org.bytedeco', name: 'ffmpeg-platform', version: '4.4-1.5.6'
  }
  </code></pre>
  <p>I have read a lot of postings about it. When I run the application, I see the following error:</p>
  <pre><code>Process: de.mw.talk2drone, PID: 30330
      java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/android-aarch64/libjnidispatch.so) not found in resource path
  </code></pre>
  <p>I tried a lot of ways to include the file com/sun/jna/android-aarch64/libjnidispatch.so in the apk, but nothing worked for me. Using</p>
  <pre><code>implementation 'net.java.dev.jna:jna:5.10.0@aar'
  </code></pre>
  <p>aborts the compilation with &quot;Duplicate class&quot;.</p>
  <p>The App has to run on a Google Pixel 4a 5g.</p>
  <p>Any hints are appreciated.</p>