thp / apkenv Goto Github PK
View Code? Open in Web Editor NEWA compatibility layer for applications packaged as .apk. Can run certain Android games on non-Android Linux (glibc and others).
License: Other
A compatibility layer for applications packaged as .apk. Can run certain Android games on non-Android Linux (glibc and others).
License: Other
apkenv ====== A compatibility layer for applications packaged as .apk. Support website: http://thp.io/2012/apkenv/ 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: http://thp.io/2011/trg2/ "Installing" applications ========================= apkenv now includes a very rudimentary facility to "install" an .apk as an application. What it really does is extract the icon from the .apk (this might not work for all .apks - we'd need to read the manifest to get the real file name and application name in all cases) and create a launcher icon that starts apkenv with the apk file as its argument. To use it, type: apkenv --install /path/to/your.apk please note that installing is not supported on the pandora port yet. softfp vs. hardfp ================= Android is softfp. Maemo 5 is softfp. MeeGo 1.2 Harmattan is hardfp. Pandora is softfp. 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: __attribute__((pcs("aapcs"))) 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 headaches. 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, etc..). 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). apkenv now also has some more in depth debugging options (see --help), for example tracing calls to bionic libraries (-ta -u), while running an app this will show you which bionic functions are called from the app and if the crash happens soon after one of the bionic functions is called try adding this function to the hooks, in some cases this has helped us to fix crashes. Documentation ============= JNI Invocation API http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/invocation.html JNI Functions http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html JNI Types and Data Structures http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/types.html GCC Function Attributes http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html ARM Hard Float Point: VFP Comparison http://wiki.debian.org/ArmHardFloatPort/VfpComparison Android MotionEvent http://developer.android.com/reference/android/view/MotionEvent.html 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 - http://www.winimage.com/zLibDll/minizip.html Copyright (C) 1998-2010 Gilles Vollant (minizip) Copyright (C) 2007-2008 Even Rouault Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) apklib/ioapi_mem.c: ioapi implementation for accessing .zip files in memory Copyright (C) 1998-2003 Gilles Vollant Copyright (C) 2003 Justin Fletcher imagelib/stb_image.h: stb_image - v2.27 - public domain image loader - http://nothings.org/stb Copyright (c) 2017 Sean Barrett linker/*: The Android Bionic Linker + The Android Bionic C Library Copyright (c) 2005-2008, The Android Open Source Project jni/jni.h: 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 Pandora Port ============ All code written by me (crowriot) for apkenv's pandora port is licensed under same conditions as the apkenv itself.
I think, it would be better to move all SDL sound code from support modules to apkenv binary. Then will be possible move support modules between platforms without recompile it to different SDL versions. As for evdev and joystick code.
On SailfishOS accelerometer reading is not working due to SDL_JoystickOpen(0) returning NULL with SDL error: "There are 0 joysticks available"
feof is defined as a macro in bionic, the FILE struct in harmattan differs from the one in bionic causing feof to be broken.
Hi. I've been analyzing your source code as I found strange that even very simple Acivity/layout application don't work on apkenv.
So the problem, as I see it, is that your are trying to find a shared library with apk_get_shared_library, but there is none. If I understand correctly this function checks the apk as a zip for "lib/armeab" folder. But my app doesn't contain even the lib folder. It just doesn't use any except those built into Android.
For me it seems that apkenv returns a wrong message. Or maybe even there would be a way to run much larger set of apk just by omitting trying to load the libraries?
Hello world app:
http://m.enux.pl/_native/hello/HelloAndroid.zip
The app built with Netbeans:
http://m.enux.pl/_native/hello/HelloAndroid-debug.apk
http://m.enux.pl/_native/hello/HelloAndroid-debug-unaligned.apk
In case this is still alive, the compilation fails on the RPi 3, similar to this issue with:
In file included from compat/gles2_wrappers.c:4:0:
/opt/vc/include/GLES2/gl2.h:49:26: error: two or more data types in declaration specifiers
/opt/vc/include/GLES2/gl2.h:49:1: warning: useless type name in empty declaration [enabled by default]
If I use @krnlyng 's RPi2 branch, the compilation gets almost finished, failing at:
libEGL.so undefined reference to "XCreateImage"
and 4 other similar libEGL errors just with different references.
I am getting this error compiling apkenv on Raspberry Pi 2:
...
-e CC linker/strlcpy.o
-e CC linker/dlfcn.o
-e CC compat/gles2_wrappers.o
In file included from compat/gles2_wrappers.c:4:0:
/opt/vc/include/GLES2/gl2.h:49:26: error: two or more data types in declaration specifiers
/opt/vc/include/GLES2/gl2.h:49:1: warning: useless type name in empty declaration [enabled by default]
makefile:84: recipe for target 'compat/gles2_wrappers.o' failed
make: *** [compat/gles2_wrappers.o] Error 1
Any ideas ?
user@ml1:/big/src/apkenv$ make
makefile:33: Using SDL 1.2 libraries
CC compat/gles2_wrappers.o
: error: two or more data types in declaration specifiers
make: *** [makefile:89: compat/gles2_wrappers.o] Error 1
Unfortunately make isn't giving me the line of gles2_wrappers.c that it doesn't like.
The structs end with semicolons, so that's correct. Idk what else could be the problem.
Are there any plans to make apkenv work on Ubuntu touch?
Is it possible to get a platform file for the raspberry pi, i have managed to get libsdl-gles to compile and install, if it works is another matter..
Since there wasn't a platform file and the n9xx code wouldn't compile (references to sdl1.3 ?) i tryed pandora=1
Currently getting a egl surface on screen but the program kicks out the following
http://i.imgur.com/C1qEb1D.png
Is it possible to embed it in ApkEnv compiler libraries from Android? Wanted to run some apps on Maemo, but faced with the lack of libraries.
I compiled apkenv on my Allwinner A10 linux device (using pandora for platform and maemo for gles). I maked some changes in imagelib and headers to fix compile errors (it does not build with actual libpng, zlib, libjpeg versions) It is working on my device, but running games does not respond to any touch events.
I added some tracing calls (printf("native input %d %d %d %d\n",event,x,y,finger); before native input call).
Input events are sent:
native input 1 435 241 0
x,y are true.
What is wrong?
Only trg2 responds to touch events.
O.K the problem was in hardfp (SOFTFP disabled on pandora).
-e CC (TH) debug/wrappers/wrapper_code_thumb.o
/tmp/ccQR3dE2.s: Assembler messages:
/tmp/ccQR3dE2.s:25: Error: invalid register list to push/pop instruction -- push {r0-r11,lr}' /tmp/ccQR3dE2.s:26: Error: selected processor does not support Thumb mode
ldrd r0,fun'
/tmp/ccQR3dE2.s:28: Error: selected processor does not support Thumb mode ldrd r1,name' /tmp/ccQR3dE2.s:29: Error: selected processor does not support Thumb mode
ldrd r2,str'
/tmp/ccQR3dE2.s:30: Error: selected processor does not support Thumb mode ldrd r4,tc' /tmp/ccQR3dE2.s:32: Error: invalid register list to push/pop instruction --
pop {r0-r11,lr}'
/tmp/ccQR3dE2.s:40: Error: lo register required -- `ldr pc,fun'
make: *** [debug/wrappers/wrapper_code_thumb.o] Error 1
linker/dlfcn.c:267:17: error: initializer element is not constant
linker/dlfcn.c:267:17: note: (near initialization for ‘apkenv_libdl_symtab[6].st_value’)
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 6.3.1 20170109 (GCC)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.