将自定义SO文件导入AOSP [英] importing custom SO file to AOSP

查看:211
本文介绍了将自定义SO文件导入AOSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照本教程构建了AOSP系统服务: http://www.androidenea.com/2009/12 /adding-system-server-to-android.html

I've built an AOSP system service following this tutorial: http://www.androidenea.com/2009/12/adding-system-server-to-android.html

现在,我想使用一个预编译的.so文件,并且无法弄清楚放在哪里,因此我的代码可以访问它了.

Now I want to use a pre-compiled .so file and cannot figure out where to put it so my code will be able to access it.

所以,我在framewaork/base/libs/my_folder/下创建了一个文件夹 并放两个文件: my_lib.so android.mk

so, i created a folder at framewaork/base/libs/my_folder/ and put there two files: my_lib.so android.mk

android.mk的内容为:

the content of the android.mk is :

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE:= my_lib
LOCAL_MODULE_TAGS := optional

include $(BUILD_SHARED_LIBRARY)

make运行时没有错误,但是当代码尝试通过以下方式加载库时: System.loadLibrary("my_lib");

the make ran without errors, but when the code tried to load the library via: System.loadLibrary("my_lib");

我收到此错误:

06-27 13:58:55.581:E/AndroidRuntime(806):由以下原因引起:java.lang.UnsatisfiedLinkError:未找到库my_lib;尝试过[/vendor/lib/my_lib.so、/system/lib/my_lib.so]

06-27 13:58:55.581: E/AndroidRuntime(806): Caused by: java.lang.UnsatisfiedLinkError: Library my_lib not found; tried [/vendor/lib/my_lib.so, /system/lib/my_lib.so]

所以我将so文件添加到out/target/product/generic/system/lib 但出现了相同的错误.

so i added the so file to out/target/product/generic/system/lib but got the same error.

那么我应该在哪里放置my_lib.so文件?并且需要android.mk吗? 也许我应该在系统上的某个地方注册它?

so where should i place the my_lib.so file ? and is an android.mk needed for it ? maybe i should register it somewhere on the system ?

提前谢谢!

推荐答案

所以答案很简单. 我真的需要将我的库复制到系统映像,再复制到system/lib文件夹,因为make命令不会将它从out/target/product/generic/system/lib复制到system.img

So the answer was quite simple. I really need to copy my lib to the system image, to the system/lib folder, because the make command doesn't copy it from out/target/product/generic/system/lib to system.img

诀窍是添加此行

  PRODUCT_COPY_FILES += $(LOCAL_PATH)/my_lib.so:system/lib/my_lib.so

到full.mk文件.它的位置是: android-source/build/target/product 也把my_lib.so放在它附近 (如路径所示)

to full.mk file. it's location is: android-source/build/target/product also put the my_lib.so near it (as seen by the path)

如果打算在实际设备上运行映像,请在设备名称定义之后添加此行. 例如如果您在Nexus 4上运行,请将其放在android-source/device/lge/mako/full_mako.mk

if you are planning to run the image on a real device, add this line after the device name definition. f.ex. if you are running on Nexus 4, put it at android-source/device/lge/mako/full_mako.mk

这篇关于将自定义SO文件导入AOSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆