This question already has an answer here:
- Android studio, gradle and NDK 23 answers
I am trying my hands on developing a simple android application in which I am trying to use sqlcipher, which uses .so libraries internally. I have read the documentation on how to use sqlcipher with android app. I have followed the steps and it compiles without any error. But, at runtime it throws UnsatisfiedLinkError
.
Googling around for it, I found that, gradle doesn\'t support .so libraries yet, but I found a hack here which I am trying to use. But it throws compile time error at line #40 on the gist which is,
tasks.withType(com.android.build.gradle.PackageApplicationTask) { pkgTask ->
pkgTask.jniDir new File(buildDir, \'native-libs\')
}
saying
Could not find property \'com\' on Project \'MyProject\'
Here I am posting code from my build.gradle file.
buildscript {
repositories {
maven { url \'http://repo1.maven.org/maven2\' }
}
dependencies {
classpath \'com.android.tools.build:gradle:0.4\'
}
}
apply plugin: \'android\'
dependencies {
compile files(\'libs/android-support-v4.jar\')
compile files(\'libs/commons-codec.jar\')
compile files(\'libs/guava-r09.jar\')
compile files(\'libs/sqlcipher.jar\')
}
targetCompatibility = 1.6
sourceCompatibility = 1.6
android {
target = \'android-14\'
compileSdkVersion 17
buildToolsVersion \"17.0.0\"
defaultConfig {
minSdkVersion 9
targetSdkVersion 16
}
}
task copyNativeLibs(type: Copy) {
from(new File(project(\':MyProject\').buildDir, \'native-libs\')) { include \'**/*.so\' }
into new File(buildDir, \'native-libs\')
}
tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }
clean.dependsOn \'cleanCopyNativeLibs\'
tasks.withType(com.android.build.gradle.PackageApplicationTask) { pkgTask ->
pkgTask.jniDir new File(buildDir, \'native-libs\')
}
Can, anybody please help me on what I have done wrong or what should I do to include those .so libraries in my apk?
As I am new to android development and gradle, please apologize me if I have misunderstood something.