unsatisfiedlinkerror - Android Unit Test and .so file [Linker Error] -


we using different sets of .so files debug , release versions. build.gradle contains followign things:

sourcesets { debug {         main.jnilibs.srcdirs = ['libs/debug']         test.jnilibs.srcdirs = ['libs/debug']       } release {         main.jnilibs.srcdirs = ['libs/release']         test.jnilibs.srcdirs = ['libs/release']         } } 

the .so files within libs/debug , libs/release folder. application works fine apk created both release , debug mode. android unit test cases fail error:

java.lang.unsatisfiedlinkerror: dlopen failed: "/data/data/com.test.mapp/app_files/.???" has bad elf magic     @ java.lang.runtime.load(runtime.java:331) 

what reason? wil not work if use both debug , release version of .so files adding subfolders (debug/release) within libs folder? 1 more thing add here works fine if use 1 set (debug/release) of .so files in libs folder , use following format in build.gradle

sourcesets { main.jnilibs.srcdirs = ['libs'] test.jnilibs.srcdirs = ['libs'] } 

update[08-11-2016]: crash observed when application debug apk run on device or emulator. release apk fine. .so files different folders debug/arm64-v8a,debug/mips etc. based on guess apk not picking .so files libs/debug subfolders properly.

if try run unit test on development machine can't use native modules compiled android.

to use native modules in tested classes must run test on device or emulator, creating instrumented unit test: https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests.html


Comments