Search code examples
fluttergradle

2 files found with path 'lib/arm64-v8a/libpdfium.so' from inputs


I'm working on a project where I need to render a PDF with clickable actions (such as opening a link contained in the file).

I added this flutter package to my project : pdfrx: ^1.0.74

However at the build compilation I caught this error :

Execution failed for task ':pdfrx:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction
   > 2 files found with path 'lib/arm64-v8a/libpdfium.so' from inputs:
      - /Users/_/Projects/front-flutter/build/pdfrx/intermediates/merged_jni_libs/debug/out/arm64-v8a/libpdfium.so
      - /Users/_/Projects/front-flutter/build/pdfrx/intermediates/cxx/Debug/3p4usq1y/obj/arm64-v8a/libpdfium.so
     If you are using jniLibs and CMake IMPORTED targets, see
     https://developer.android.com/r/tools/jniLibs-vs-imported-targets

On this Github issue a dude is sharing a solution. He propose to put this code in the graddle of the version (which is for me a bad practice) - but it is still not working and I'm getting the same error :

packagingOptions {
  pickFirst '**/libpdfium.so'
}

Does anybody have an idea of how to fix this error ?


Solution

  • A temporary solution would be to make a fork or modify the gradle file of the package version that you are using :

    $HOME/.pub-cache/hosted/pub.dev/pdfrx-1.0.74/android/build.gradle

    packagingOptions {
        pickFirst 'lib/x86/libpdfium.so'
        pickFirst 'lib/x86_64/libpdfium.so'
        pickFirst 'lib/armeabi-v7a/libpdfium.so'
        pickFirst 'lib/arm64-v8a/libpdfium.so'
    }
    
    

    Until that you can wait for the author to make an update or you can try to make a pull request.