Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
113 lines (78 sloc) 3.65 KB
A compatibility layer for applications packaged as .apk.
Support website:
Example module and .apk
An example module is provided in modules/trg2.c - you can use this module as a
basis to create your own modules. You can download the .apk that works with
this example module from:
softfp vs. hardfp
Android is softfp.
Maemo 5 is softfp.
MeeGo 1.2 Harmattan is hardfp.
softfp and hardfp differ in the way functions with floating point arguments
get called. Trying to call a hardfp function with the softfp calling
convention will not work and likely result in a crash or worse. To avoid
this, you can add an attribute to function declarations to make sure that
the function accepts its parameters using the softfp calling convention,
like this:
There's a convenience #define in apkenv.h called "SOFTFP" with which you can
decorate all functions that are either in a native library (i.e. in
modules/) or that will be called from the native library (i.e. in compat/).
Please note that in theory this attribute is only required on functions that
pass float values in the arguments, but do it always to save you some
Debugging crashes
First of all, enable debugging in the makefile (set DEBUG=1). Then rebuild
to get a debug build with lots of debug output. You can then check which
symbols get mapped from where at the linker phase (e.g. apkenv x.apk | grep
'from libc') - in general, most libc functions must be mapped in order to
avoid problems (e.g. stdio functions don't work in Bionic libc, so we have
to hack around these issues - the same is true for memory (de-)allocation,
When you have all relevant functions mapped, ltrace'ing apkenv can help you
find the library function in which it crashes - this will not list functions
from Bionic libs, but only from your system libraries (another reason why it
is usually a good idea to map system-level functions).
JNI Invocation API
JNI Functions
JNI Types and Data Structures
GCC Function Attributes
ARM Hard Float Point: VFP Comparison
Android MotionEvent
Third Party Code
All code written by me (thp) for apkenv is licensed under a simplified BSD
license (see LICENSE.apkenv). However, code from third parties might be
licensed under a different license, and have different copyright holders:
apklib/unzip.{c,h}, apklib/ioapi.{c,h}:
The MiniZip project -
Copyright (C) 1998-2010 Gilles Vollant (minizip)
Copyright (C) 2007-2008 Even Rouault
Copyright (C) 2009-2010 Mathias Svensson ( )
ioapi implementation for accessing .zip files in memory
Copyright (C) 1998-2003 Gilles Vollant
Copyright (C) 2003 Justin Fletcher
The Android Bionic Linker + The Android Bionic C Library
Copyright (c) 2005-2008, The Android Open Source Project
libnativehelper: Support functions for Android's class libraries
Copyright (C) 2006 The Android Open Source Project
compat/hooks.c, compat/pthread_wrapper.c:
pthread wrapper implementation based on code from libhybris
Copyright (C) 2012 Carsten Munk