android ndk library,Android NDK - Library not found

I work with Android Studio and Android NDK.

My folder "src/main/jni" contains the following files:

Android.mk

Application.mk

HelloWorld.cpp

Application.mk

APP_ABI := all

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := HelloWorld

LOCAL_SRC_FILES := HelloWorld.cpp

include $(BUILD_SHARED_LIBRARY)

In my Java code, I load the library:

static{

System.load("HelloWorld");

}

I run ndk-build as below and it runs without error: ndk-build -C src/main

build.gradle contains:

sourceSets.main {

jniLibs.srcDirs 'src/main/libs'

jni.srcDirs = [] //disable automatic ndk-build call

}

libHelloWorld.so is compiled and copied to the folders:app\src\main\libs\arm*\

The root directory of app-debug.apk contains a lib directory.

libHelloWorld.so exists in all subdirectories (lib\arm*)

When I deploy and debug the application on the LG Nexus 4 device, I get the following error:

9-24 18:50:51.486 20352-20352/ndk.tests.firstndk E/art﹕ dlopen("HelloWorld", RTLD_LAZY) failed: dlopen failed: library "HelloWorld" not found

09-24 18:50:51.489 20352-20352/ndk.tests.firstndk D/AndroidRuntime﹕ Shutting down VM

09-24 18:50:51.491 20352-20352/ndk.tests.firstndk E/AndroidRuntime﹕ FATAL EXCEPTION: main

Process: ndk.tests.firstndk, PID: 20352

java.lang.UnsatisfiedLinkError: dlopen failed: library "HelloWorld" not found

at java.lang.Runtime.load(Runtime.java:331)

at java.lang.System.load(System.java:981)

at ndk.tests.firstndk.MainActivity.(MainActivity.java:11)

at java.lang.reflect.Constructor.newInstance(Native Method)

Could you please help to solve this issue? Why my native lib cannot be loaded? What is wrong with my configuration?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值