当前位置:编程学习 > wap >>

关于android jni 调用已存在的SO

请各位帮我看下我的 问题出在哪了
这是Applcition.mk的内容
APP_PROJECT_PATH := $(call my-dir)
APP_MODULES      := libtutorial-zeroone libtutorial-zerotwo
这是Android.mk的内容
LOCAL_PATH:= $(call my-dir)

# first lib, which will be built statically
#
include $(CLEAR_VARS)

LOCAL_MODULE    := first
LOCAL_SRC_FILES := first.c

include $(BUILD_SHARED_LIBRARY)

# second lib, which will depend on and include the first one
#
include $(CLEAR_VARS)

LOCAL_MODULE    := second
LOCAL_SRC_FILES := second.c


LOCAL_SHARED_LIBRARIES := first

include $(BUILD_SHARED_LIBRARY)

两个C文件的内容
first内容
#include "first.h"

int  first(int  x, int  y)
{
    return x + y;
}
second.c内容
#include "first.h"
#include <jni.h>

jint
Java_com_example_twolibs_TwoLibs_add( JNIEnv*  env,
                                      jobject  this,
                                      jint     x,
                                      jint     y )

{
// void*  filehandle = dlopen("/data/data/com.example.twolibs/libtwolib-first.so", RTLD_LAZY ); 
    return first(x, y);
}


可以编译成功
但运行时会报错:
java.lang.UnsatisfiedLinkError: Library second not found
--------------------编程问答-------------------- LOCAL_SHARED_LIBRARIES := first 应该写成LOCAL_SHARED_LIBRARIES := ./first --------------------编程问答-------------------- 应该是这个
LOCAL_SHARED_LIBRARIES := first 应该写成LOCAL_SHARED_LIBRARIES := /first --------------------编程问答--------------------
引用 2 楼 onlinetomcat 的回复:
应该是这个
LOCAL_SHARED_LIBRARIES := first 应该写成LOCAL_SHARED_LIBRARIES := /first

不行啊 现在又一种方法解决 就是push 到/sysytem/lib 下可以
但是每次这样push好累啊 谁还有什么号得解决方法啊
补充:移动开发 ,  Android
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,