JNI 调用.a 静态库文件

============================================================
博文原创,转载请声明出处
============================================================

android工程共需要ffmpeg,引入源码进行ndk-build编译,每次需要十五分钟左右,于是想吧编译出来的.a文件直接拿过来使用。

网上东拼西凑总算成功了,这里吧脚本分享给大家。

在jni目录下创建Android.mk和Application.mk文件,如下,修改相应内容进行编译,ok。

Android.mk

# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE    := AndroidCamera 

LOCAL_SRC_FILES := AndroidCamera.cpp \
					CameraSelf/CCamDevice_Init.c \
					newBuffer/bufferqueue.cpp \
					newBuffer/mymalloc.cpp \
					CameraSelf/TcpChannel_Connect.c \
					newDecoder/DecodeLib.cpp \
					CameraSelf/CCamDevice_MAIN.cpp \
					

LOCAL_STATIC_LIBRARIES := libavformat libavcodec libswscale libavutil libpostproc  ffmpeg

LOCAL_C_INCLUDES := $(LOCAL_PATH)/newBuffer \
					$(LOCAL_PATH)/newDecoder \
					$(LOCAL_PATH)/newDecoder/ffmpeg \
					$(LOCAL_PATH)/CameraSelf \



LOCAL_ARM_MODE := arm
LOCAL_CFLAGS :=  -D__STDC_CONSTANT_MACROS -I$(LOCAL_PATH)/newDecoder/ffmpeg/ 


LOCAL_LDLIBS += -llog
include $(BUILD_SHARED_LIBRARY)
include $(call all-makefiles-under,$(LOCAL_PATH)/newDecoder)


Application.mk

APP_CFLAGS += -fexceptions
#APP_STL := gnustl_static
APP_STL := stlport_static
APP_ABI := armeabi


原文地址:https://www.cnblogs.com/javawebsoa/p/3047794.html