androidandroid-ndkgradle-experimental

How to limit target platform with android gradle-experimental?


When running my android application Android Studio prints error:

Error:Execution failed for task ':app:processAndroidArmDebugJniLibs'.
> java.io.FileNotFoundException: <path here>\distribution\wb\lib\x86\libwb.so (The system cannot find the path specified)

It tries to access x86 library but I tried to limit target platforms only to arm platform. Error is gone if I replace ${targetPlatform.getName()} with armeabi in app.gradle (gradle-experimental) file:

model {
repositories {
    libs(PrebuiltLibraries) {
        wb {
            binaries.withType(SharedLibraryBinary) {
                sharedLibraryFile = file("${lib_distribution_root}/wb/lib/${targetPlatform.getName()}/libwb.so")
            }
        }
    }
}
android {
    // ...
    sources {
        main {
            jniLibs {
                dependencies {
                    library "wb"
                }
            }
        }
    }
    productFlavors {
        create("arm") {
            ndk.abiFilters.add("armeabi")
        }
    }
}
// ...

How to fix build so that only arm library is used?


Solution

  • You can add ndk.abiFilters in build.gradle:

    
        android {
            ....
            defaultConfig {
            ndk {
                abiFilters 'armeabi'
                }
            }
            ....
        }