LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) TARGET_PLATFORM := android-3 LOCAL_MODULE := serial_port LOCAL_SRC_FILES := SerialPort.c #LOCAL_LDLIBS := -llog LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog LOCAL_SHARED_LIBRARIES += \ libcutils libutils LOCAL_MODULE_TAGS := optional eng include $(BUILD_SHARED_LIBRARY) 出现过错误:添加 LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog LOCAL_SHARED_LIBRARIES += \ libcutils libutils
后问题解决 PLATFORM_VERSION_CODENAME=RELPLATFORM_VERSION=4.0.4TARGET_PRODUCT=msm8x25_y300TARGET_BUILDSPEC=TARGET_BUILD_VARIANT=engTARGET_BUILD_TYPE=releaseTARGET_BUILD_APPS=TARGET_ARCH=armTARGET_ARCH_VARIANT=armv7-a-neonHOST_ARCH=x86HOST_OS=linuxHOST_BUILD_TYPE=releaseBUILD_ID=IMM76I============================================No private recovery resources for TARGET_DEVICE msm8x25_y300make: Entering directory `/home/yuanwei/code/8x25'target SharedLib: serial_port (out/target/product/msm8x25_y300/obj/SHARED_LIBRARIES/serial_port_intermediates/LINKED/serial_port.so)prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: out/target/product/msm8x25_y300/obj/SHARED_LIBRARIES/serial_port_intermediates/SerialPort.o: in function Java_android_1serialport_1api_SerialPort_close:external/serial/SerialPort.c:168: error: undefined reference to '__android_log_print'prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: out/target/product/msm8x25_y300/obj/SHARED_LIBRARIES/serial_port_intermediates/SerialPort.o: in function Java_android_1serialport_1api_SerialPort_open:external/serial/SerialPort.c:101: error: undefined reference to '__android_log_print'prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: out/target/product/msm8x25_y300/obj/SHARED_LIBRARIES/serial_port_intermediates/SerialPort.o: in function Java_android_1serialport_1api_SerialPort_open:external/serial/SerialPort.c:103: error: undefined reference to '__android_log_print'prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: out/target/product/msm8x25_y300/obj/SHARED_LIBRARIES/serial_port_intermediates/SerialPort.o: in function Java_android_1serialport_1api_SerialPort_open:external/serial/SerialPort.c:117: error: undefined reference to '__android_log_print'collect2: ld returned 1 exit statusmake: *** [out/target/product/msm8x25_y300/obj/SHARED_LIBRARIES/serial_port_intermediates/LINKED/serial_port.so] Error 1结果:No private recovery resources for TARGET_DEVICE msm8x25_y300make: Entering directory `/home/yuanwei/code/8x25'target SharedLib: serial_port (out/target/product/msm8x25_y300/obj/SHARED_LIBRARIES/serial_port_intermediates/LINKED/serial_port.so)target Symbolic: serial_port (out/target/product/msm8x25_y300/symbols/system/lib/serial_port.so)target Strip: serial_port (out/target/product/msm8x25_y300/obj/lib/serial_port.so)Install: out/target/product/msm8x25_y300/system/lib/serial_port.so
生成了serial_port.so并改为libserial_port.so 后打包到APK的libs/armeabi 目录下。