如何使用 Eclipse 在 apk 中包含预构建的共享库 [英] how to include prebuilt shared libraries in apk with eclipse
问题描述
我有一个共享库 libfoo.so,需要在我的 Android 应用程序中使用它.
I have a shared library libfoo.so and need to use it in my android app.
我的第一次尝试是在 Android.mk 中:
My first try was to have in Android.mk:
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_SRC_FILES := test.cpp
LOCAL_LDLIBS := -L$(PATH_TO_FOO) -lfoo
include $(BUILD_SHARED_LIBRARY)
在我的活动中,我有:
statis
{
System.loadLibrary("foo");
}
这可以正确构建,但是我注意到创建的 apk 不包含 libfoo.so(我也看到它没有复制到 libs/armeabi).我猜出于这个原因,我在执行我的应用程序时遇到了 UnsatisfiedLinkError.
This builds correctly, however I noticed that created apk doesnt include libfoo.so (also I see it is not copied to libs/armeabi). I guess for that reason I have UnsatisfiedLinkError when executing my app.
我在其他一些帖子中看到我需要添加 $(PREBUILD_SHARED_LIBRARY),所以我将以下内容添加到我的 Android.mk:
I saw in some other posts that I need to add $(PREBUILD_SHARED_LIBRARY), so I add the following to my Android.mk:
include $(CLEAR_VARS)
LOCAL_MODULE:= foo
LOCAL_SRC_FILES := $(FOO_PATH)/libfoo.so
include $(PREBUILD_SHARED_LIBRARY)
但现在我收到构建错误:
But now I am getting the build error:
foo: LOCAL_SRC_FILES points to a missing file.
我确定路径是正确的.请注意,libfoo.so 在末尾有原来的版本号,尽管我不得不删除它(并且只留下 .so),因为 ndk-build 抱怨了.
I am sure that the path is correct. Note that the libfoo.so was having origionally the version number at the end, though I had to remove it (and leave only .so) since ndk-build complained.
我做错了什么?
推荐答案
include 似乎拼写错误:
The include appears to be misspelt:
include $(PREBUILD_SHARED_LIBRARY)
应该是
include $(PREBUILT_SHARED_LIBRARY)
这篇关于如何使用 Eclipse 在 apk 中包含预构建的共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!