Android apk - How to exclude a .so file from a 3rd party dependency using gradle

Mathieu Gardere

I have an android project with several dependencies. Two of them (let's call them dependency A and B) have native libraries (.so files).

Dependency A has the following architectures: arm64-v8a, armeabi, armeabi-v7a, x86 and x86_64. Dependency B has the following architectures: armeabi, x86

Thus when my app runs on an armeabi-v7a device (for instance), and dependency B calls a native method, it cannot find the relevant library to get it from (as it is not present in armeabi-v7a folder and does not fall back automatically to armeabi where the library is).

Is there any way to work around this? For instance, can I add some configuration to my build.gradle file in order for arm64-v8a, armeabi-v7a, and x86_64 folders not to be integrated to my final apk?

I have tried packagingOptions / exclude, but with no results : the folders in questions are still there.

Deji

Try a clean build, I didn't and it was still picking up the files from the previous build. I ended up deleting my app/build/ folder just to be sure.

android { 
    packagingOptions {
        exclude 'lib/armeabi-v7a/libSomeLibYouDontWant.so'
    }
}

Worked for me on an app that was previously crashing.

An alternative would be to use

android{
    defaultConfig{
        ndk{
            abiFilters "armeabi", "x86"
        }
    }
}

There are some similar questions which might be helpful

Gradle exclude arm64 libs

How to use 32-bit native libraries on 64-bit Android device

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to exclude file from resources using Gradle and Android Studio?

From Dev

How to exclude 3rd party CDI bean factory from Quarkus Arc bean resolution?

From Dev

how to get the xpath from Katalon studio's testObject in 3rd party jar file

From Dev

How to find instruction from 3rd party shared library that caused an android native crash?

From Dev

How to install 3rd party module so that it is loaded on boot?

From Dev

How to install 3rd party module so that it is loaded on boot?

From Dev

how to use 3rd party library on android?

From Dev

How to block ads in a 3rd party app: Android

From Dev

how to recompile the 3rd party jars using lower version

From Dev

How to parse this 3rd party JSON service using .NET?

From Dev

How to parse this 3rd party JSON service using .NET?

From Dev

How to call 3rd party Erlang module from Elixir?

From Dev

How to make a maven sub-dependency "provided" in 3rd party dependency?

From Dev

How do you compile a static library that has a 3rd party dependency without including the dependency?

From Dev

How can I convert a UNC Windows file path to a File URI without using any 3rd party tools or by hand?

From Dev

How to exclude a file from an .AAR Android library archive with gradle

From Dev

In an Android Gradle build, how to exclude dependencies from an included jar file?

From Dev

What portion of 3rd party android library is included when generating apk?

From Dev

Exclude Package From Gradle Dependency

From Dev

Exclude project from a dependency in Gradle

From Dev

How can I list all 3rd party jars in an apk?

From Dev

Gradle: Exclude file from Android assets folder

From Dev

How can I exclude from Gradle dependency lists after the fact?

From Dev

Gradle: How to include Java project flavor dependency resources into Android APK?

From Dev

Compilation using 3rd party libraries

From Dev

Using a 3rd party control

From Dev

Compilation using 3rd party libraries

From Dev

android license for jar file from 3rd library

From Dev

How to integrate a 3rd party class library with Laravel so it autoloads?

Related Related

  1. 1

    How to exclude file from resources using Gradle and Android Studio?

  2. 2

    How to exclude 3rd party CDI bean factory from Quarkus Arc bean resolution?

  3. 3

    how to get the xpath from Katalon studio's testObject in 3rd party jar file

  4. 4

    How to find instruction from 3rd party shared library that caused an android native crash?

  5. 5

    How to install 3rd party module so that it is loaded on boot?

  6. 6

    How to install 3rd party module so that it is loaded on boot?

  7. 7

    how to use 3rd party library on android?

  8. 8

    How to block ads in a 3rd party app: Android

  9. 9

    how to recompile the 3rd party jars using lower version

  10. 10

    How to parse this 3rd party JSON service using .NET?

  11. 11

    How to parse this 3rd party JSON service using .NET?

  12. 12

    How to call 3rd party Erlang module from Elixir?

  13. 13

    How to make a maven sub-dependency "provided" in 3rd party dependency?

  14. 14

    How do you compile a static library that has a 3rd party dependency without including the dependency?

  15. 15

    How can I convert a UNC Windows file path to a File URI without using any 3rd party tools or by hand?

  16. 16

    How to exclude a file from an .AAR Android library archive with gradle

  17. 17

    In an Android Gradle build, how to exclude dependencies from an included jar file?

  18. 18

    What portion of 3rd party android library is included when generating apk?

  19. 19

    Exclude Package From Gradle Dependency

  20. 20

    Exclude project from a dependency in Gradle

  21. 21

    How can I list all 3rd party jars in an apk?

  22. 22

    Gradle: Exclude file from Android assets folder

  23. 23

    How can I exclude from Gradle dependency lists after the fact?

  24. 24

    Gradle: How to include Java project flavor dependency resources into Android APK?

  25. 25

    Compilation using 3rd party libraries

  26. 26

    Using a 3rd party control

  27. 27

    Compilation using 3rd party libraries

  28. 28

    android license for jar file from 3rd library

  29. 29

    How to integrate a 3rd party class library with Laravel so it autoloads?

HotTag

Archive