It’s been awfully quiet around here, to the point where the last post made is more than a year ago. In the meantime I did not disappear from the face of the earth, but have been busy with putting together the Android and C++ part of the PSPDFKit SDK. My year was filled with writing blogs and talks there as well. DroidCons I talked about how to implement cross-platform development across Android, iOS, Linux, Windows and OS X with C++ and all the challenges that come from that.
This week I had the dubius honor of trying to find out why a native subsystem of PSPDFKit is performing orders of magnituted slower than it should. As it turns out, NDK tooling on Android is exceptionally bad. A quick Google search found two ways of profiling NDK code running on an Android device: 1. Using android-ndk-profiler project from GitHub. This project provides missing gnu_mcount method implementation needed by -pg compile flag instrumentation.
If you updated your device from Android 5.1 to 6.0 without wiping all data you noticed that the quick setting and home button have stopped working. That because the OS thinks the setup wizard is running and it’s trying to prevent you from escaping it. If you check logcat you’ll see a Not starting activity because user setup is in progress message when you press the home button. To get rid of the issue, you have to manually start the setup wizard so it sets the “initial setup succeeded” flag.
C and C++ compilers aren’t the fastest pieces of software out there and there’s no lack of programmer jokes based on tedium of waiting for their work to complete. There are ways to fix the pain though - one of them is ccache. CCache improves compilation times by caching previously built object files in private cache and reusing them when you’re recompiling same objects with same parameters. Obviously it will not help if you’re compiling the code for the first time and it also won’t help if you often change compilation flags.
Publishing Gradle AAR libraries is one of the bigger pain points with Android’s new build system - it’s not as integrated and direct as it is with the Maven build system. Pretty much anyone has his/hers own solution to this problem and here is mine based on published FuzzyDateFormatter library. 1. Generate JavaDoc and source JARs Both Maven Central and jCenter require you to publish a JavaDoc and Source JARs for your public projects.
The trick to playing video with effects on Android is to use OpenGL for actual frame display and then use (API 11+) SurfaceTexture class to render video as a texture on screen. See GitHub for full app demo. The process has two steps: 1. Initialize OpenGL Context to render on a SurfaceTexture Since there is no SurfaceTexture equivalent of GLSurfaceView we have to initialize an OpenGL context manually. In bottom example we initialize OpenGL ES 2.0 context with disabled depth buffer prepared for 2D video rendering. We also define abstract draw metod to be extended with our drawing logic.
Pretty much any Android developer has the same complaint: the emulator is slow to start and slower to run, making app testing very annoying. In last Android Development Tools iterations Google implemented several ways to speed up the emulator to make it usable.
Android is a platform that for better or for worse runs on wide variety of devices and causes a lot of “fragmentation” complaints by less experienced developers. And while the screen/resolution issues can be decently solved by having a competent designer (see: web development), version fragmentation poses a more significant problem - only 7.1% of all Android devices run 4.x versions, while the rest are suck on older Androids with little hope for update. Android version distribution Ice Cream sandwich (and Honeycomb before it) brought significant improvements to the Android API, which significantly ease cross-device development and thanks to efforts of several developers a large part of those changes were backported in form of libraries for Android 2.x. The most headache-easing libraries for Android development I’ve found so far are:
There is a writing on the wall of my workplace tea room that states “If you’re not ashamed of version 1.0, you haven’t shipped soon enough”. Well, the original version of Prevoz.org application made for Mobitel competition was bad enough to prevent me from showing it to people :). The tabbed interface felt clunky even at the original release and Android application moved away from that interface paradigm awhile ago. Also the design would cause alot of serious implementation problems with new features.
As karma has it, the Bicikel app had a pretty noticeable bug after being released - if the phone took some time to lock its location, the station list did not sort correctly. Also, the full station map view didn’t really show any useful information beyond the station position. So now I released Bicikel 1.1 for Android with bugfixes and new station list and map coloring, so the user can see stations that are either full or empty at first glance.