How to allow specific ABIs for specific native libraries?
<p>I need to filter my 3-rd party native libraries and allow only "armeabi" for all of them. With one exception! - a specific library must be included in its "armeabi-v7a" variant. </p>

<p>How can I filter my 3rd party native libraries differently depending on the library? (or on the app module)</p>

<p>What I want in my APK in the end is:</p>

<ul>
<li>armeabi / lib-1.so</li>
<li>armeabi / lib-2.so</li>
<li>armeabi / lib-3.so</li>
<li>armeabi-v7a / special-lib.so</li>
</ul>

<p><strong>The full story:</strong> </p>

<p>I have an app built in a couple of modules. It uses a few 3rd party native libraries. Until now, we were only using "armeabi" versions of all libraries, since they are most compatible, and since we aim for low app size (without multiple APK's). However, now we need to include a new 3rd party library that is only available in "armeabi-v7a" form.</p>

<p>We've been using the filter:</p>

<pre><code>productFlavors {
        app {
            ndk {
                abiFilters "armeabi"
}}}
</code></pre>

<p>It's located in the main app module. It filters all native libraries from all modules and libraries. Now we are forced to use this filter:</p>

<pre><code>productFlavors {
        app {
            ndk {
                abiFilters "armeabi", "armeabi-v7a"
}}}
</code></pre>

<p>Which makes the app work but also increases its size significantly. We don't want to use it. It allows the armeabi-v7a version of the new library, but it also allows the armeabi-v7a versions of a few other libraries that we don't want to include. </p>

<p><strong>The question:</strong> We want to allow "armeabi-v7a" only for one specific library which resides in one of our app modules. Can we achieve that by ABI filters or some other way?</p>

<p><em>Note about 64-bit:</em> I know that in case you have ANY 64 bit native libraries, you need to have all of them (cause if the app finds one 64-bit lib, it will start in 64-bit mode and will not be able to use the 32-bit libs). However, in the case of armeabi vs armeabi-v7a there is no such problem and you don't have to supply both versions of each lib.</p>