AndroidStudio編譯faac的so動(dòng)態(tài)庫(kù)

下載faac源碼包,地址:https://sourceforge.net/projects/faac/files/faac-src/faac-1.28/,注意要下載.tar.gz的,我試過(guò).zip中的源碼用ndk編譯不通過(guò)。

EE114470-0930-461C-904C-8E72F62DAEDD.png

然后創(chuàng)建一個(gè)android項(xiàng)目工程,并創(chuàng)建一個(gè)jni目錄,并將源碼所有文件全部粘貼到j(luò)ni目錄下,如圖:


QQ20180907-153844@2x.png

其中有一個(gè)config.h.in文件,直接去掉后面的.in,讓擴(kuò)展名為.h,否則在frame.h中會(huì)報(bào)錯(cuò)。
并在jni根目錄中創(chuàng)建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目錄中創(chuàng)建一個(gè)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項(xiàng)目,執(zhí)行完后,在如圖目錄下生成了libfaac.so


QQ20180907-154756@2x.png

或者在jni目錄中執(zhí)行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
QQ20180907-162829@2x.png

肯定有哥們懶的不愿意自己編譯,那我也把編譯好的so庫(kù)貢獻(xiàn)出來(lái)了,下載地址:https://download.csdn.net/download/xy1213236113/10652226,希望給個(gè)好評(píng)!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容