Skip to main content

Posts

Showing posts from July, 2014

Android Native CPU ABI

Every piece of native code generated with the Android NDK matches a given ABI(Application Binary Interface). ABI defines exactly how machine code is expected to interact with the system at runtime. ABI describes following things at runtime: the CPU instruction set that the machine code should use the endianness of memory stores and loads at runtime the format of executable binaries (shared libraries, programs, etc...) and what type of content is allowed/supported in them. various conventions used to pass data between your code and the system (e.g. how registers and/or the stack are used when functions are called, alignment constraints, etc...) alignment and size constraints for enum types, structure fields and arrays. the list of function symbols available to your machine code at runtime, generally from a very specific selected set of libraries. Android Supported ABIs: 1.armeabi: This ABI is for ARM-based CPUs that support at least the ARM

Overview of how to develop native code with Android NDK:

  Create a jni directory and place native source code under $PROJECT/jni/... Create Android.mk directory and place it under $PROJECT/jni/... to describe source code to the NDK build system. Create Application.mk and place it under $PROJECT/jni/...to describe project in more details to the NDK build system.It is an optional. Finally need to build native source code by running '$NDK/ndk-build' from project directory or it's sub-directory. Android.mk An Android.mk file is a small build script that we write to describe sources to the NDK build system. It's syntax is like this... LOCAL_PATH:=$(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:=hello-jni LOCAL_SRC_FILES:=hello-jni.c include $(BUILD_SHARED_LIBRARY) NDK groups your sources into "modules", where each module can be one of the following: Static library Shared library We can write several module in a single 'Android.mk' or can write seve

NDK(Native Development Kit)

NDK is a set of tools that allows Android application developers to embed native machine code compiled c/c++ source file into their application packages. Note- Android NDK can only be used to target Android system images running cupcake(1.5) or later versions of the platform. Android NDK Goals: The DVM allows application's source code to call methods implemented in native code through the JNI. This means that: Applications source code will be declare one or more methods with the 'native' keyword to indicate that they are implemented through native code. native byte[] loadFile(String filepath); Must have a native shared library that contains the implementation of these methods, which will be packed into application's .apk. LibFileloader.so Application must explicitly load the library. Static{ System.loadLibrary(FileLoader); } Don't use 'lib'prefix and '.so' suffix. Android NDK is a compl

Android Interview Topics

Android Application Components Activities OnCreate() OnStart() OnResume() OnPause() OnRestart() OnStop() OnDestroy() Services Started Bound OnStartCommand() OnBind() OnCreate() OnDestroy() Content Providers Content Provider Basics Creating a Content Provider Calender Provider Contacts Provider Broadcast Receivers Normal Broadcasts Ordered Broadcasts Android Tools ADB(Android Debug Bridge) ADT(Android Developer Tools) AVD(Android Virtual Devices) Manager BMGR Device Monitor DMTracedump Draw 9-path Emulator etc1tool Hierarchy Viewer HPROF Converter JOBB Lint Logcat Mksdcard Monkey MonkeyRunner ProGuard SDK Manager Systrace Tracer for OpenGLES TraceView Uiautomator Zipalign Process And Thread Process Lifecycle Foreground Process Visible Process Service P