天天看点

androidStudio编译faac为动态库

下载faac源码包,地址:https://sourceforge.net/projects/faac/files/faac-src/faac-1.28/,注意要下载.tar.gz的,我试过.zip中的源码用ndk编译不通过。
androidStudio编译faac为动态库
然后创建一个android项目工程,并创建一个jni目录,并将源码所有文件全部粘贴到jni目录下,如图:
androidStudio编译faac为动态库

其中有一个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:

然后再在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
androidStudio编译faac为动态库
或者在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-    
Android NDK: WARNING: APP_PLATFORM android- is higher than android:minSdkVersion  in /Users/xuyan/androidproject/AACProject/faac/src/main/AndroidManifest.xml. NDK binaries will *not* be compatible with devices older than android- 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::: 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::: 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::: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
 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::: 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::: 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::: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
 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::: 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::: 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::: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
 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::: 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::: 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::: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
 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
           
androidStudio编译faac为动态库
肯定有哥们懒的不愿意自己编译,那我也把编译好的so库贡献出来了,下载地址:https://download.csdn.net/download/xy1213236113/10652226,希望给个好评!

继续阅读