add cpp classes into android project

送分小仙女□ 提交于 2019-12-11 05:50:01

问题


How can I add a .cpp class (like speex or opus) into my android studio project ? I already tried to insert using externalNativeBuild like :

externalNativeBuild {
        ndkBuild {
            arguments "NDK_APPLICATION_MK:=Application.mk"
            abiFilters "armeabi", "armeabi-v7a", "x86"
            cFlags "-I\$(LOCAL_PATH)/jnispeex.cpp -I\$(LOCAL_PATH)/jnicelt11.cpp -I\$(LOCAL_PATH)/jnicelt7.cpp -I\$(LOCAL_PATH)/jniopus -D__EMX__ -DUSE_KISS_FFT -DFIXED_POINT -DEXPORT='' -DHAVE_CONFIG_H -fvisibility=hidden -DOPUS_BUILD -DVAR_ARRAYS -Wno-traditional -DFIXED_POINT"
        }
    }

but it does't work. I will be so appreciated if anyone helps


回答1:


you should use CMakelists.txt for your Android NDK build and configure your CPP files inside the Cmakelists.txt. Some related links for your reference:

  1. https://stackoverflow.com/a/51182431/8034839

  2. Where to place JNI/native libraries in Android Studio Project



来源:https://stackoverflow.com/questions/52125375/add-cpp-classes-into-android-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!