Home button not working after flashing to Android Marshmallow

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. On Android 6.0 the activity is called SetupWizardTestActivity and can be invoked via adb with:

adb shell am start -n com.google.android.setupwizard/.SetupWizardTestActivity

Click through the wizard and the issue will disappear.

Continue reading

Use ccache with CMake for faster compilation

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. Most C/C++ development however involves recompiling same object files with the same parameters and ccache helps alot.

For illustration, here’s the comparison of first and subsequent compilation times of a largish C++ project:

Original run with empty cache
make -j9
real 0m56.684s
user 5m31.996s
sys 0m41.638s
Recompilation with warm cache
make -j9
real 0m5.929s
user 0m11.896s
sys 0m8.722s


CCache is available in repositories on pretty much all distributions. On OS X use homebrew:

brew install ccache

and on Debian-based distros use apt:

apt-get install ccache

CMake configuration

After ccache is installed, you need to tell CMake to use it as a wrapper for the compiler. Add these lines to your CMakeLists.txt:

# Configure CCache if available
find_program(CCACHE_FOUND ccache)

Rerun cmake and next make should use ccache for wrapper.

Usage with Android NDK

CCache can even be used on Android NDK - you just need to export NDK_CCACHE environment variable with path to ccache binary. ndk-build script will automatically use it. E.g.

export NDK_CCACHE=/usr/local/bin/ccache
ndk-build -j9

(Note that on Debian/Ubuntu the path will probably be /usr/bin/ccache)

CCache statistics

Continue reading

Encoding videos for YouTube with FFMpeg

One of the most commonly asked questions on Freenode/#ffmpeg is how to use it to encode videos for YouTube in accordance to Googles Recommended upload encoding settings. Conforming to the guideline is rather simple, but not straightforward for the newcomer.

1. Get newish ffmpeg

Get decently new and updated ffmpeg - the current stable release is 2.7.


brew install ffmpeg


Get a 64-bit static build from Zeranoe’s site.


Get a 64-bit static build from Linux static build site.

2. The command line

ffmpeg -i <input file> -codec:v libx264 -crf 21 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart <output_name>.mp4

This should suffice for full conformity. Explanation of parameters used:

Continue reading

Talk about live web video streaming on WebCamp Ljubljana

Live video streaming is still a touchy subject and not well supported across browsers and mobile devices. Hence I did a short overview of how to start on this years WebCamp Ljubljana. The lecture has since been published as a video as well.

Relevant links from the slides:

Pre-built FFMpeg downloads - Official FFMpeg site with precompiled ffmpeg builds for major platforms

Nginx RTMP module - Video streaming server module for Nginx with RTMP, (Apple) HLS and DASH support

Video.js HTML5 video player - Free HTML5 video player that automatically detects browser capabilities and switches to Flash when necessary

Media sources and HLS modules for Video.js player required for HLS live streaming support

Lecture video

The lecture video and slides:

Continue reading

Apache Solr Webcamp talk slides and links

This week, on april 26th, I gave a talk about Solr basics on WebCamp Ljubljana. Here I’m listing the slides, tips and the relevant links for anyone starting up with Solr.

Here I’m listing relevant links from the slide-deck which are good starting point for Solr deployment.

Reference guide

Apache Solr Reference Guide / Wiki - Use this for main reference, for some reson all Google links go to obsolete Solr Wiki.

Points of interest in the reference guide:

Language analysis - Guides for Solr configuration for different languages

Filter reference guide - List of all Lucene filters available in Solr with descriptions

Character filter reference guide - List of all Lucene filters working on character level (e.g. ščž -> scz collapse, punctuation removal, etc.)

Configuration examples

Basic Solr Home - a minimal Solr home configuration with two cores configured for slovene and english language

NewsBuddy - an opensource full-text search site for news articles. It has a nice example of how to effectively configure Solr for Slovenian articles.

LemmaGen Slovenian lemmatizer - Solr plugin for slovenian lemmatization

Solr libraries

Solr Client Libraries - List of Solr client libraries

PySolarized - My Solr/Python communication library with multilanguage support

Slide deck

Continue reading

Playing video with effects using OpenGL on Android

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.

Continue reading

Jernej Virag

Software developer, Android herder at PSPDFKit, gamer and professional flamewar starter. Pacify with great quantities of icecream or chocolate.

Senior Android Developer @ PSPDFKit GmbH

Ljubljana, Slovenia