1. 程式人生 > >Eclipse中Android開發引用第三方庫

Eclipse中Android開發引用第三方庫

Android.mk檔案編寫

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE   := IDataEncapsulation #生成的庫名
LOCAL_CPPFLAGS := -DJSON_IS_AMALGAMATION -fexceptions #-Wwrite-strings  #編譯選項
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog #需要連線的庫檔案
#   依賴的原始檔
LOCAL_SRC_FILES :=  jsoncpp.cpp src/function.cpp    \                 
                    src/protocol.cpp    \
                    src/DeviceInit
/deviceInit.cpp \ src/PositionData/positionData.cpp \ src/RouteRecord/routeRecord.cpp \ src/DeviceData/deviceData.cpp \ src/RequestAck/requestAck.cpp \ src/ExtendData/extendData.cpp LOCAL_ALLOW_UNDEFINED_SYMBOLS
:= true APP_PLATFORM := android-14 #指定使用到的標頭檔案路徑 LOCAL_C_INCLUDES += $(LOCAL_PATH) \ $(LOCAL_PATH)/inc \ $(LOCAL_PATH)/inc/DeviceInit \ $(LOCAL_PATH)/inc/PositionData \ $(LOCAL_PATH)/inc/RouteRecord \ $(LOCAL_PATH)/inc/DeviceData \ $(LOCAL_PATH)/inc/RequestAck \ $(LOCAL_PATH
)/inc/ExtendData \ include $(BUILD_SHARED_LIBRARY) #表示生成動態庫檔案 #引用第三方庫檔案 include $(CLEAR_VARS) LOCAL_MODULE := libencapsulatedIData LOCAL_SRC_FILES := prebuilt/libencapsulatedIData.so include $(PREBUILT_SHARED_LIBRARY) #引用第三方庫檔案 include $(CLEAR_VARS) #LOCAL_CPPFLAGS := -DJSON_IS_AMALGAMATION -fexceptions #LOCAL_CPPFLAGS := -DJSON_IS_AMALGAMATION -fexceptions LOCAL_MODULE := libjsoncpp LOCAL_SRC_FILES := prebuilt/libjsoncpp.so include $(PREBUILT_SHARED_LIBRARY)
  1. libs、obj目錄裡面的檔案是IDE臨時生成的,能夠通過clean清理掉。
  2. 把需要編譯進apk的,或者引用的第三方庫檔案放在prebuilt目錄下。