Gradle include everything in the flavors libs folder (compile the fileTree file folder as a whole) Edit: set sourcedir for each flavor for files

Therefore, I want to include all files and subdirectories in the flavors file structure. What I'm doing here includes all the jar and so files in the libs folder, but I also want to include directories.

I tried turning it on include ['*'], but that didn't work. I also looked back a little at the answer, but walked over shortly. What is the correct way to accomplish this?

dependencies {
    //format for including lib files for all flavors
    compile fileTree(dir: 'libs', include: ['*.jar'])
    //format for including all jars and so in pdf flavor
    //pdfCompile fileTree(dir: 'libs', include: ['*.jar'])
    pdfCompile fileTree(dir: 'src/pdf/libs', include: ['*.jar','*.so'])
}

When the application starts, the following exception tells me that not all .so files are included.

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.company.appname-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libPDFNetC-v7a.so"

Edit: Below is my file structure. FYI: src is a child of my module and is a brother of libs. enter image description here

+4
2

, , , , , , .

, , gradle jar , libs, flavorCompile filetree.

, flavor.jniLibs.srcDir sourceSets android. ( , ) flavors libs .

enter image description here

  apply plugin: 'com.android.library'

    android {
        compileSdkVersion 21

        buildToolsVersion "21.1.2"
        publishNonDefault true
        defaultConfig {
            minSdkVersion 16
            targetSdkVersion 21
        }
        //product flavors merge their respective folders in src with main
        productFlavors{
            pdf{}
            nopdf{}
        }
        buildTypes {
            release{
                minifyEnabled false
                //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                 }
            debug{ minifyEnabled false }
        }
    sourceSets{
        pdf.jniLibs.srcDirs = ['src/pdf/libs']
    }
    }
    dependencies {
        //format for including lib jar files for all flavors
        compile fileTree(dir: 'libs', include: ['*.jar'])
        //libs jar files for specific flavor
        pdfCompile fileTree(dir: 'src/pdf/libs', include: ['*.jar'])
    }
+4

?

1 libs . , myModule/src/flavourName. 1 build.gradle , libs.

, libs . , , build.gradle . , .

EDIT: @Theyouthis, , . , , ​​:

module1/
      libs/
      src/
         flavour1/
         flavour2/
         flavour3/
      build.gradle

, libs/, .

+1

All Articles