We are trying to use a third party .a static library in our Android app. The .a lib is built for x86 and we used it with a PC linux box without problem.
Then we try to use it on Android with this Android.mk:
LOCAL_PATH:= $(call my-dir)
# first lib, which will be built statically
#
include $(CLEAR_VARS)
LOCAL_MODULE := libtwolib-first
LOCAL_SRC_FILES := rwl.a
LOCAL_MODULE_SUFFIX := .a
include $(PREBUILT_STATIC_LIBRARY)
# second lib, which will depend on and include the first one
#
include $(CLEAR_VARS)
LOCAL_MODULE := libtwolib-second
LOCAL_SRC_FILES := second.c
LOCAL_STATIC_LIBRARIES := libtwolib-first
include $(BUILD_SHARED_LIBRARY)
We get this error:
could not read symbols: File in wrong format
Is it because the .a file is compiled with x86 and we are building for arm?
The .a file is a legacy and most likely can’t be recompiled from source. If this is the issue, is there any other solution?
Thanks.
You need to obtain the source for the third-party lib and cross-compile it to native Android’s NDK such that its binary compatible.
Simply dropping an x86 static lib into Android’s NDK build will just not work.