Update: Adding the NDK (JNI) build to an Eclipse project
In a previous post, I explored the use of the OpenSL ES library to implement audio IO natively on Android. This required the creation of a JNI library, which was added to the Eclipse project for the App. In that case, we would run a build script from the command line by changing to the project directory and running
$ sh build.sh
The contents of build.sh were discussed in that post.
To facilitate things, we can incorporate the build script by going into the Eclipse project properties (right click on the project and select ‘properties’) and:
- choose ‘Builders’
- click on ‘New’
- select ‘Program’
- give it a name: ‘JNI build’
- On the ‘Main’ tab, in ‘Location’, add the path to your bash command: e.g. /bin/sh
- Same tab, in Working Directory, click on Browse Workspace and select your project.
- Same tab, in Arguments, add your build script name: e.g. build.sh
- On the Environment tab, click on ‘New’:
- Create a PATH variable and add your command path to it (e.g. /usr/bin:/usr/local/bin:/usr/sbin:/bin:/sbin)
- Click on OK.
- On the Builder list window, click ‘up’ to move the JNI build to the top of the list.
This will integrate the JNI build in your Eclipse project. The example project in GIT has been updated with these changes:
$git clone https://bitbucket.org/victorlazzarini/android-audiotest