Chapter 3
Going Native
IN THIS CHAPTER
Connecting C code to Kotlin code
Creating an Android app with native code
Sometimes, you have to get your hands dirty. You have to pop the hood and figure out why smoke comes out of your car. You have to bake a cake for that special friend who's allergic to the ingredients in store-bought cakes. Or, in order to build the perfect mobile app, you must bypass Android's comfortable Kotlin coating and dig deep to find your true inner geek. You must create part of an app in the primitive, nuts-and-bolts, down-and-dirty language called C (or, if you want to use object-oriented programming techniques, C++).
Developers have depended on low-level programming languages like C/C++ for years to give them an advantage and that’s what this chapter is about. Instead of driving the minivan of apps, you can drive a souped-up Ferrari. Of course, just as a Ferrari requires in-depth maintenance, your souped-up app will require special skills to maintain as well. Besides discovering how to work with native code using the Native Development Kit (NDK), you also discover the pros and cons of using this approach.
The Native Development Kit
The creators of Android realized that developers would want to use non-Kotlin code. So Android has a framework that mediates ...
Get Android Application Development All-in-One For Dummies, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.