Home » Android » android – native-audio sample in NDK build problem

android – native-audio sample in NDK build problem

Posted by: admin June 15, 2020 Leave a comment


i have a problem when build native-audio sample in NDK.
The main reason is “SLES/OpenSLES.h: No such file or directory”

I have googled but i dont find any thing helpful.

Please help me.

Thanks in advance

How to&Answers:

If you are building from the commandline, try

ndk-build TARGET_PLATFORM=android-9


it is due to your android version . specify android version when build.

ndk-build TARGET_PLATFORM=android-9


I’ve also got this problem but now, it works.
You should use exactly the Android API 9.
In Eclipse, create a new project from existing source (the native-audio sample) whose target is Android 2.3.1, then, build the shared library with ndk-build. Finally build your project in Ecclipse by the common way to do that.
Hope it will help you.


If you are using Android Studio and an Application.mk file. Set the android platform version with:

//replace 'x' with the platform version you are targeting
APP_PLATFORM := android-x

Click here for ndk-r10c reference. I am using ndk-r10e and it still uses the same variable.


in Android Studio you can solve this problem by adding the following line to the project.properties file:

target=android-23 // replace 23 with the api you are targeting

the project.properties file should be located inside the “main” directory, if it’s not there you can create the file and it should work fine.