So I want to include all files and sub-directories in a flavors file-structure. What I am doing here is including all jar and so files in the libs folder but I also want to include directories.
I tried include include ['*']
but that didn't work. I also looked around for an answer for a while but came up short. What is the correct way of accomplishing this?
dependencies {
//format for including lib files for all flavors
compile fileTree(dir: 'libs', include: ['*.jar'])
//format for including all jars and so's in pdf flavor
//pdfCompile fileTree(dir: 'libs', include: ['*.jar'])
pdfCompile fileTree(dir: 'src/pdf/libs', include: ['*.jar','*.so'])
}
When running app 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 sibling of libs.
I think I could have found a solution by switching up my search criteria, but for those who make the same mistake I will show how I solved this issue.
It seems the real issue was that gradle can only handle jar files in a flavors designated libs folder when using the flavorCompile filetree method.
You can overcome this by designating a flavor.jniLibs.srcDir
in sourceSets under android. For the file structure below (Which is in a module that I am refusing to show) you can separate a flavors libs files like so.
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'])
}