Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Developing for android using NDK

 
Ashley Riot
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the NDK provide all the tools and utilities that can be found in Java SDK? Is there an advantage to developing using the SDK instead of the NDK?
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The NDK provides access to a small set of native libraries (http://developer.android.com/tools/sdk/ndk/index.html#Tools), like OpenGL. And it has provisions for letting you implement methods in C/C++, going so far as making it possible to implement the entire lifecycle of an Activity in native code if you need to. It does not make available all the Java libraries to C code.
 
Jeffrey Friesen
Author
Ranch Hand
Posts: 67
5
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ashley,

A few months ago, I wrote about the Android NDK for Apress's "Android Recipes, Second Edition" book, which is being promoted on JavaRanch this week.

My NDK chapter (which also covers Renderscript) discusses NDK installation, explores the various tools that the NDK makes available, itemizes NDK examples that are part of the NDK, and provides sample programs. The first sample, NDKGreetings, presents the Java and C sides of what I'd call a hybrid app. The Java side loads a native NDKGreetings library and proceeds to invoke its getGreetingMessage() native method in the app activity's onCreate() method. The C side uses JNI to return a message from the native equivalent of getGreetingMessage(). Moving forward from this simple JNI demo, I present low-level and high-level native activities in the C language. I show how to create and run all of these examples in command-line and Eclipse IDE contexts. I believe this chapter (8) will answer your questions for you.

All the best.

Jeff Friesen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic