Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android gradle, native libs for different architectures

I am trying to build universal apk for all architectures. Here is my project structure:

-App
    -appModule
    -libraryModule
         -libs
             -armeabi
                 -lib.so
         -src
             -java
             -jni

Here is my gradle file for libraryModule:

apply plugin: 'com.android.library'

//    http://stackoverflow.com/questions/28485309/how-to-build-single-apk-with-andoid-ndk-and-gradle


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        ndk {
            moduleName "ProxyResolver" // <-- This is the name of AndroidProxy native module
            stl "gnustl_shared"
            cFlags "-std=c++11"
            abiFilters = ['armeabi']
            ldLibs (projectDir.absolutePath + "/libs/armeabi/libresolver.so")
        }
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

As you can see the path for library is hardcoded. And right now it works on arm-v7 processors. But i need to add support of x86 without adding a flavor

like image 693
Vetalll Avatar asked Jan 15 '16 12:01

Vetalll


Video Answer


1 Answers

I guess:

ndk {

    moduleName "resolver"
    stl "gnustl_shared"
    cFlags "-std=c++11"
    abiFilters = ['armeabi','arm-v7']
}

And remove

sourceSets {
    main {
        jniLibs.srcDirs = ['libs']
    }
}
like image 156
tiny sunlight Avatar answered Oct 17 '22 16:10

tiny sunlight