有一个非常完整的答案,同样的问题在这里:http://grokbase.com/t/gg/android-ndk/125v31e6wy/play-store-market-filtering-of-ndk-libs
让我发表我自己的解决方案,这几乎是我在这里张贴相同:Android library .so with x86 architecture missing? (Vuforia)
所以你有一个常规的Android.mk,不能在x86架构上编译,因为你使用的库(libExternalLibrary.so)只提供给arm archi。 你想建立一个基于这个库的.so(libMyLibraryBasedOnExternalLibrary.so),当然,如果没有这个库,它不会永远不会编译。
这个想法是直接在Android.mk中使用条件编译指令直接为x86生成虚拟库。
1)创建2个虚拟.cpp文件Dummy0.cpp和Dummy1.cpp为例Dummy0.cpp看起来是这样的:
#include <jni.h>
#include <android/log.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <string>
#ifdef __cplusplus
extern "C"
{
#endif
int dummy0 = 0;
#ifdef __cplusplus
}
#endif
然后,编辑了Android。MK是建立资料库,并修改它是这样的:
LOCAL_PATH := $(call my-dir)
ifeq ($(TARGET_ARCH_ABI), armeabi)
# In this condtion block, we're compiling for arm architecture, and the libExternalLibrary.so is avaialble
# Put every thing the original Android.mk was doing here, importing the prebuilt library, compiling the shared library, etc...
# ...
# ...
else
# In this condtion block, we're not compiling for arm architecture, and the libExternalLibrary.so is not availalble.
# So we create a dummy library instead.
include $(CLEAR_VARS)
# when LOCAL_MODULE equals to ExternalLibrary, this will create a libExternalLibrary.so, which is exactly what we want to do.
LOCAL_MODULE := ExternalLibrary
LOCAL_SRC_FILES := Dummy0.cpp
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
# This will create a libMyLibraryBasedOnExternalLibrary.so
LOCAL_MODULE := MyLibraryBasedOnExternalLibrary
# Don't forget to tell this library is based on ExternalLibrary, otherwise libExternalLibrary.so will not be copied in the libs/x86 directory
LOCAL_SHARED_LIBRARIES := ExternalLibrary
LOCAL_SRC_FILES := Dummy1.cpp
include $(BUILD_SHARED_LIBRARY)
endif
当然,要确保在你的代码时,您的应用程序在x86上运行的唯一设备,你从来没有调用库:
if ((android.os.Build.CPU_ABI.equalsIgnoreCase("armeabi")) || (android.os.Build.CPU_ABI2.equalsIgnoreCase("armeabi"))) {
// Good I can launch
// Note that CPU_ABI2 is api level 8 (v2.2)
// ...
}
可能解决/嘲笑的想法:http://stackoverflow.com/questions/15146174/android-library-so-with-x-86-architecture-missing-vuforia – auselen