1

similar questions have been asked:

How to run NDK samples?

Making Android NDK apps with NativeActivity?

I've got the command-line documentation down to the point where I can create an empty Android project, I do not know how to build-install-run the NDK examples, particularly the NativeActivity one, in a non-Eclipse build environment (Ubuntu 10.0.04).

So my questions are

  1. does the NativeActivity example "just work" or do you have to do something besides just $adb -d shell "am start -a android.intent.action.MAIN -n com.example.nativeActivity"?
  2. How do you build, install, run the NativeActivity example?
Community
  • 1
  • 1
T. Webster
  • 9,605
  • 6
  • 67
  • 94

1 Answers1

5

I can't answer about this specific example. But here's the general process for building and installing an Android application which uses the NDK.

  1. cd to the root of its source code.
  2. Run ndk-build. This builds the native code, and should result in some .so files being put into the libs directory.
  3. android update project --path . --name something
  4. ant debug (or similar). This will build the Java code and create an .apk. Crucially, the build process will pick up the .so files left within the libs directory and include them into the .apk.
  5. adb install bin/name-of-project.apk
  6. Then launch as normal using the Android GUI or using an am start command such as you give.
Adrian Taylor
  • 4,054
  • 2
  • 24
  • 26
  • This works perfectly fine with NativeActivty, I am using `am start` command for NativeActivity all the time. – Mārtiņš Možeiko Feb 13 '13 at 19:06
  • on building the nativeactivity example, I'm getting a make build fail: fatal error: jni.h: no such file. – T. Webster Feb 13 '13 at 22:24
  • Sorry to hear that - not sure what's up, but Googling for that problem shows various possible solutions even here on Stack Overflow. – Adrian Taylor Feb 13 '13 at 22:27
  • @AdrianTaylor I got this one myself (no Google!) it was an `include` issue. check out my other question to see hwo I solved it http://stackoverflow.com/questions/14866739/include-jni-h-and-compile-with-arm-linux-gnueabi-gcc – T. Webster Feb 14 '13 at 23:23
  • Don't forget to add an API target to the tail of your command: android update project --path . --name projectname --target 20 – class Nov 11 '14 at 03:03