add cpp classes into android project

2019-03-03 02:51发布

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条回答
闹够了就滚
2楼-- · 2019-03-03 03:24

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

查看更多
登录 后发表回答