Your SlideShare is downloading. ×
Android NDK Overview
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Android NDK Overview

1,198
views

Published on

Brief Introduction to android NDK

Brief Introduction to android NDK

Published in: Technology, Education

1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total Views
1,198
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
1
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1.
      26 MAR 2011
      www.blrdroid.org
        Android NDK
        Badrinath Kulkarni Member, Bangalore Android User Group [ B.A.U.G ]
    • 2.
        26 MAR 2011
        www.blrdroid.org
          What is NDK ?
        • NDK – Native Development Kit.
        • 3. NDK is a complement to the Android SDK.
        • 4. NDK is a tool to embed native code C / C++.
        • 5. NDK available for platforms >= 1.5 [Cupcake].
      • 6.
          26 MAR 2011
          www.blrdroid.org
            Goal of NDK
            Provide set of cross-tool chains that can generate native binaries for ARMv5TE, ARMv7-A. X86 in future.
            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
            Provide tool to package native library into .APK.
            Also, provides documentations, sample examples of native code.
        • 7.
            26 MAR 2011
            www.blrdroid.org
              Why Native Code ?
            • For skilled C / C++ developers.
            • 8. Porting existing C / C++ or other native code.
            • 9. High Performance.
            • 10. Option for more memory.
          • 11.
              26 MAR 2011
              www.blrdroid.org
                When Native Code ?
                NDK is not to write apps in native code.
                For high performance tasks like graphics. Ex: Games
                Needs good understanding of JNI.
                In NDK r5, we can also implement the Android application lifecycle in native code with help from the new NativeActivity class.
            • 12.
                26 MAR 2011
                www.blrdroid.org
                  Java Native Interface [JNI]
                  Java App
                  Dalvik
                  Native Library
                  JNI
                  Host Environment
              • 13.
                  How JNI works ? (1/2)
                  Dynamically Load library
                  keyword
                  Call as normal method
                  26 MAR 2011
                  www.blrdroid.org
                • 14.
                    How JNI works ? (2/2)
                    “ Java_<package>_<class>_<method>”
                    A JNI interface pointer
                    A Java object pointer
                    Method parameters
                    26 MAR 2011
                    www.blrdroid.org
                  • 15.
                      How JNI works ? (2/2)
                      “ Java_<package>_<class>_<method>”
                      A JNI interface pointer
                      A Java object pointer
                      Method parameters
                      26 MAR 2011
                      www.blrdroid.org
                        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);
                    • 16.
                        Building Native Code
                        Root directory for native code
                        26 MAR 2011
                        www.blrdroid.org
                      • 17.
                          Program Output
                          26 MAR 2011
                          www.blrdroid.org
                        • 18.
                            @ iBadrinath
                            26 MAR 2011
                            www.blrdroid.org