Include .jnilib in custom Gradle Plugin

plugins
not-a-bug

(Paul Sprotte) #1

Hey lovely Community,
i’m trying to write an own custom Gradle Plugin for Android. The Plugin uses pngquant to reduce the filesize of all pngs in the drawable folder. In detail it is using the c++ lib from https://pngquant.org/lib/ see “Compiling and Linking” -> “To build Java JNI interface run: make java”. On my local machine everything works fine because i set the jnilib insite intellij. But when use the lib from Gradle within an test project it cant find the pngquantlib in the java.library.path. I tried basically everything i could find in the internet and in this forum using the jni keyword in the search. Maybe anyone has a hint to point me in the right direction?
You can also find my project under https://github.com/Sprotte/Android-PNGQuant-Drawable-Optimizer in the moment without anything i tried like:
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir ‘src/main/libs’
}
etc.