Android NDK Exception failed: dlopen failed: could not find the symbol "_ZN7Tangram11setPositionEdd" referenced by "libtangram.so",

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?

+8
c ++ android android-ndk jni
source share
1 answer

It looks like you tried to compile the tangram project from your own ndk-build, unlike their recommended build process ( https://github.com/tangrams/tangram-es#android ). Use their build process with make to create the libtangram.so file, and then copy this .so file to the native library directory for your application.

The reason he cannot find these characters is because you do not include the corresponding source files that define these functions when created with ndk. By entering undefined characters, it will compile, but cannot resolve them at run time.

The missing character is created from Tangram::setPosition(double, double) , which is defined in https://github.com/tangrams/tangram-es/blob/master/core/src/tangram.cpp#L318 ; however, your Android.mk file does not include this source file.

+1
source share

All Articles