我有一个共享库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(我也看到它是不会被复制到库/ 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是其一端origionally的版本号,但我不得不将其删除(只留下。所以),因为NDK建造抱怨。
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 $(PREBUILD_SHARED_LIBRARY)
应
include $(PREBUILT_SHARED_LIBRARY)