androidStudio編譯faac爲動態庫

下載faac源碼包,地址:https://sourceforge.net/projects/faac/files/faac-src/faac-1.28/,注意要下載.tar.gz的,我試過.zip中的源碼用ndk編譯不通過。
這裏寫圖片描述
然後創建一個android項目工程,並創建一個jni目錄,並將源碼所有文件全部粘貼到jni目錄下,如圖:
這裏寫圖片描述
其中有一個config.h.in文件,直接去掉後面的.in,讓擴展名爲.h,否則在frame.h中會報錯。
並在jni根目錄中創建Android.mk和Application.mk文件。

Android.mk:

LOCAL_PATH := $(call my-dir)
FAAC_TOP := $(LOCAL_PATH)
include $(CLEAR_VARS)
include $(FAAC_TOP)/libfaac/Android.mk

Application.mk:

APP_ABI := all`

然後再在libfaac目錄中創建一個Android.mk文件。
Android.mk:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= libfaac
LOCAL_SRC_FILES:=       \
        aacquant.c      \
        backpred.c      \
        bitstream.c     \
        channels.c      \
        fft.c           \
        filtbank.c      \
        frame.c         \
        huffman.c       \
        ltp.c           \
        midside.c       \
        psychkni.c      \
        tns.c           \
        util.c          \

LOCAL_C_INCLUDES :=     \
    $(LOCAL_PATH)       \
    $(FAAC_TOP)         \
    $(FAAC_TOP)/include
LOCAL_CFLAGS:= -DHAVE_CONFIG_H
include $(BUILD_SHARED_LIBRARY)

在build.gradle中加入:

  sourceSets { main { jni.srcDirs = ['src/main/jni/'] } }
    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }

然後 rebuild Project項目,執行完後,在如圖目錄下生成了libfaac.so
這裏寫圖片描述
或者在jni目錄中執行ndk-build命令:

localhost:jni xuyan$ /Users/xuyan/Library/Android/sdk/ndk-bundle/ndk-build
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-14.    
Android NDK: WARNING: APP_PLATFORM android-14 is higher than android:minSdkVersion 1 in /Users/xuyan/androidproject/AACProject/faac/src/main/AndroidManifest.xml. NDK binaries will *not* be compatible with devices older than android-14. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.    
[arm64-v8a] Compile        : faac <= aacquant.c
[arm64-v8a] Compile        : faac <= backpred.c
[arm64-v8a] Compile        : faac <= bitstream.c
[arm64-v8a] Compile        : faac <= channels.c
[arm64-v8a] Compile        : faac <= fft.c
[arm64-v8a] Compile        : faac <= filtbank.c
[arm64-v8a] Compile        : faac <= frame.c
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: warning: 
      equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: note: 
      remove extraneous parentheses around the comparison to silence this
      warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
1 warning generated.
[arm64-v8a] Compile        : faac <= huffman.c
[arm64-v8a] Compile        : faac <= ltp.c
[arm64-v8a] Compile        : faac <= midside.c
[arm64-v8a] Compile        : faac <= psychkni.c
[arm64-v8a] Compile        : faac <= tns.c
[arm64-v8a] Compile        : faac <= util.c
[arm64-v8a] SharedLibrary  : libfaac.so
[arm64-v8a] Install        : libfaac.so => libs/arm64-v8a/libfaac.so
[x86_64] Compile        : faac <= aacquant.c
[x86_64] Compile        : faac <= backpred.c
[x86_64] Compile        : faac <= bitstream.c
[x86_64] Compile        : faac <= channels.c
[x86_64] Compile        : faac <= fft.c
[x86_64] Compile        : faac <= filtbank.c
[x86_64] Compile        : faac <= frame.c
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: warning: 
      equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: note: 
      remove extraneous parentheses around the comparison to silence this
      warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
1 warning generated.
[x86_64] Compile        : faac <= huffman.c
[x86_64] Compile        : faac <= ltp.c
[x86_64] Compile        : faac <= midside.c
[x86_64] Compile        : faac <= psychkni.c
[x86_64] Compile        : faac <= tns.c
[x86_64] Compile        : faac <= util.c
[x86_64] SharedLibrary  : libfaac.so
[x86_64] Install        : libfaac.so => libs/x86_64/libfaac.so
[armeabi-v7a] Compile thumb  : faac <= aacquant.c
[armeabi-v7a] Compile thumb  : faac <= backpred.c
[armeabi-v7a] Compile thumb  : faac <= bitstream.c
[armeabi-v7a] Compile thumb  : faac <= channels.c
[armeabi-v7a] Compile thumb  : faac <= fft.c
[armeabi-v7a] Compile thumb  : faac <= filtbank.c
[armeabi-v7a] Compile thumb  : faac <= frame.c
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: warning: 
      equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: note: 
      remove extraneous parentheses around the comparison to silence this
      warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
1 warning generated.
[armeabi-v7a] Compile thumb  : faac <= huffman.c
[armeabi-v7a] Compile thumb  : faac <= ltp.c
[armeabi-v7a] Compile thumb  : faac <= midside.c
[armeabi-v7a] Compile thumb  : faac <= psychkni.c
[armeabi-v7a] Compile thumb  : faac <= tns.c
[armeabi-v7a] Compile thumb  : faac <= util.c
[armeabi-v7a] SharedLibrary  : libfaac.so
[armeabi-v7a] Install        : libfaac.so => libs/armeabi-v7a/libfaac.so
[x86] Compile        : faac <= aacquant.c
[x86] Compile        : faac <= backpred.c
[x86] Compile        : faac <= bitstream.c
[x86] Compile        : faac <= channels.c
[x86] Compile        : faac <= fft.c
[x86] Compile        : faac <= filtbank.c
[x86] Compile        : faac <= frame.c
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: warning: 
      equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: note: 
      remove extraneous parentheses around the comparison to silence this
      warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c:829:44: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
1 warning generated.
[x86] Compile        : faac <= huffman.c
[x86] Compile        : faac <= ltp.c
[x86] Compile        : faac <= midside.c
[x86] Compile        : faac <= psychkni.c
[x86] Compile        : faac <= tns.c
[x86] Compile        : faac <= util.c
[x86] SharedLibrary  : libfaac.so
[x86] Install        : libfaac.so => libs/x86/libfaac.so

這裏寫圖片描述

肯定有哥們懶的不願意自己編譯,那我也把編譯好的so庫貢獻出來了,下載地址:https://download.csdn.net/download/xy1213236113/10652226,希望給個好評!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章