I am trying to run the Library demo application which integrates the ndk Android module. I imported this code in Android studio and also downloaded ndk and linked it to the project. The code compiles and builds successfully. This fails with the exception "ljava lang unsatisfiedlinkerror exception thrown during initialization" "failed: dlopen failed: could not find the character" _ZN7Tangram11setPositionEdd "referenced by" libtangram.so "..."
Application.mk:
APP_STL := c++_shared APP_CPPFLAGS := -frtti -fexceptions APP_ABI := armeabi armeabi-v7a x86 mips APP_PLATFORM := android-19
Android.mk:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := tangram LOCAL_SRC_FILES := jniExports.cpp jniGenerated.cpp platform_android.cpp LOCAL_LDLIBS := -llog LOCAL_ALLOW_UNDEFINED_SYMBOLS := true include $(BUILD_SHARED_LIBRARY)
Gradle Module File:
buildscript { dependencies { classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.github.dcendents:android-maven-plugin:1.2' } } apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' group = GROUP version = VERSION_NAME android { compileSdkVersion 22 buildToolsVersion "21.1.2" defaultConfig { minSdkVersion 15 targetSdkVersion 22 } sourceSets.main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] jni.srcDirs = [] assets.srcDirs = ['core/resources'] } task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') { commandLine "C:/Users/Administrator/AppData/Local/Android/android-ndk-r10e/ndk-build.cmd", 'NDK_PROJECT_PATH=build/intermediates/ndk', 'NDK_LIBS_OUT=jniLibs', 'APP_BUILD_SCRIPT=jni/Android.mk', 'NDK_APPLICATION_MK=jni/Application.mk' } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn ndkBuild } } // Add gdb server to apk afterEvaluate { Sync packageTask = project.getTasks().findByName("packageReleaseJniLibs") if (packageTask) { packageTask.include(['**/gdbserver', '**/gdb.setup']) } packageTask = project.getTasks().findByName("packageDebugJniLibs") if (packageTask) { packageTask.include(['**/gdbserver', '**/gdb.setup']) } } dependencies { compile 'com.squareup.okhttp:okhttp:2.5.0' compile 'xmlpull:xmlpull:1.1.3.1' } apply from: file('gradle-mvn-push.gradle')
In Java class load libraries:
static { System.loadLibrary("c++_shared"); System.loadLibrary("tangram"); }
I google this problem and in these posts Link1 Link2 Link3 Link4 it is mentioned that it could be a problem compiling on api 21 or later and running on older devices. But I have mentioend APP_PLATFORM: = android-19 in my Application.mk and get this exception.
Any help?
c ++ android android-ndk jni
Nouman bhatti
source share