Android NDK Overview

1,644 views

Published on

Brief Introduction to android NDK

Published in: Technology, Education
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total views
1,644
On SlideShare
0
From Embeds
0
Number of Embeds
115
Actions
Shares
0
Downloads
0
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Android NDK Overview

  1. 1. <ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul><ul>Android NDK </ul><ul>Badrinath Kulkarni Member, Bangalore Android User Group [ B.A.U.G ] </ul>
  2. 2. <ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul><ul>What is NDK ? </ul><ul><li>NDK – Native Development Kit.
  3. 3. NDK is a complement to the Android SDK.
  4. 4. NDK is a tool to embed native code C / C++.
  5. 5. NDK available for platforms >= 1.5 [Cupcake]. </li></ul>
  6. 6. <ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul><ul>Goal of NDK </ul><ul>Provide set of cross-tool chains that can generate native binaries for ARMv5TE, ARMv7-A. X86 in future. </ul><ul>Provide system headers for set of stable native API's supported in all later releases of the platform. Ex: <jni.h>,<stdio.h>,<math.h> etc </ul><ul>Provide tool to package native library into .APK. </ul><ul>Also, provides documentations, sample examples of native code. </ul>
  7. 7. <ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul><ul>Why Native Code ? </ul><ul><li>For skilled C / C++ developers.
  8. 8. Porting existing C / C++ or other native code.
  9. 9. High Performance.
  10. 10. Option for more memory. </li></ul>
  11. 11. <ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul><ul>When Native Code ? </ul><ul>NDK is not to write apps in native code. </ul><ul>For high performance tasks like graphics. Ex: Games </ul><ul>Needs good understanding of JNI. </ul><ul>In NDK r5, we can also implement the Android application lifecycle in native code with help from the new NativeActivity class. </ul>
  12. 12. <ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul><ul>Java Native Interface [JNI] </ul><ul>Java App </ul><ul>Dalvik </ul><ul>Native Library </ul><ul>JNI </ul><ul>Host Environment </ul>
  13. 13. <ul>How JNI works ? (1/2) </ul><ul>Dynamically Load library </ul><ul>keyword </ul><ul>Call as normal method </ul><ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul>
  14. 14. <ul>How JNI works ? (2/2) </ul><ul>“ Java_<package>_<class>_<method>” </ul><ul>A JNI interface pointer </ul><ul>A Java object pointer </ul><ul>Method parameters </ul><ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul>
  15. 15. <ul>How JNI works ? (2/2) </ul><ul>“ Java_<package>_<class>_<method>” </ul><ul>A JNI interface pointer </ul><ul>A Java object pointer </ul><ul>Method parameters </ul><ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul><ul>Generating Method Signature : 1. $ cd <project folder> 2. $ javah -jni -classpath ./bin com.baug.demo.BaugDemo It generates : JNIEXPORT jint JNICALL Java_com_baug_demo_BaugDemo_add (JNIEnv *, jobject, jint, jint); </ul>
  16. 16. <ul>Building Native Code </ul><ul>Root directory for native code </ul><ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul>
  17. 17. <ul>Program Output </ul><ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul>
  18. 18. <ul>@ iBadrinath </ul><ul>26 MAR 2011 </ul><ul>www.blrdroid.org </ul><ul></ul>

×