11. June 2019

How to start D-Bus in Docker container

Many Linux applications require D-Bus which is not running by default in Docker containers.

When you attempt to start the application you might get the following error:

D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
  D-Bus not built with -rdynamic so unable to print a backtrace

First of all you need to generate missing machine-id by command:

dbus-uuidgen > /var/lib/dbus/machine-id

The application will be able to start even when the daemon is not running.

To start the D-Bus daemon inside the container you need to run following command:

dbus-daemon --config-file=/etc/dbus-1/system.conf --print-address

Now the daemon is running and your application should be able to start.

8. June 2019

How to add custom mapping of a hostname to IP address in Android Emulator

There is a simple trick which allows your application to resolve a hostname to IP address defined by you even in cases when you do not have access to DNS server. This trick could be also used when you’re connected via VPN and the emulator is not able to resolve DNS record available only in private network.

Let’s add following hostname record which should be resolved by application on Android: test.georgik.rocks

First of all, you need to start your AVD with parameter ‘-writable-system’, because emulator’s filesystem is by default read-only.

Let’s get names of available AVDs.

Example for macOS:

cd ~/Library/Android/sdk/tools
./emulator -avd -list

The output might look like:


Start the emulator:

./emulator -avd "Pixel_2_API_23" -writable-system

You should see the following warning:

emulator: WARNING: System image is writable

The emulator will start. Now you need to remount the filesystem so it will become writable. This could be done via adb tool which is in platform-tools directory.

Version for macOS:

cd ~/Library/Android/sdk/platform-tools
./adb remount

Now you can start the shell and append the line with configuration to /etc/hosts:

./adb shell
echo " test.georgik.rocks" >> /etc/hosts

Now you can test the configuration by ping:

root@generic_x86_64:/etc # ping test.georgik.rocks
PING test.georgik.rocks ( 56(84) bytes of data.

7. June 2019

How to solve Android Emulator java.io.FileNotFoundException open failed: EACCES (Permission denied)

Following error in Android application is very annoying and you may waste several hours by hunting the root cause:

D/file: java.io.FileNotFoundException: /storage/emulated/0/Download/20190604_084533.jpg: 
open failed: EACCES (Permission denied)

It might occur even when the manifest is correct and contains proper permission:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

Here is sample code which will pass on file existence check, but the execution will fail on readBytes:

var file:File = File("/storage/emulated/0/Download/20190604_084533.jpg")
if (file.exists()) {
    val content:ByteArray;
    Log.d("file", "exist")
    try {
        content = f.readBytes()
     } catch (FileNotFoundException) {
        Log.d("file", e.toString())

} else {
     Log.d("file", "does not exist")

To fix this problem it is necessary to go to Settings – Apps – My App – Permission.

Access to Storage is probably disabled. Tap Storage to enable it:

With enabled Storage option, the application was able to read the file.

To solve this problem in a proper way, it’s necessary to add a request for permission to the code. Here is a sample in Kotlin:

if (checkSelfPermission(
    Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), MY_READ_EXTERNAL_REQUEST)

You can find more details about requesting permissions in Android documentation.

9. May 2019

How to switch tabs in ConEmu-Maximus5

ConEmu-Maximus5 contain simple keyboard shortcut to switch between active tabs on Windows:

CTRL + Tab – switch to the next tab
CTRL + Shift + Tab – switch to the previous tab

3. May 2019

How to install Fluxbox on Centos in Docker

Repositories which are referenced in the base image of Centos does not contain any package with lightweight X window manager like Fluxbox. If you try to install it, you’ll end up with the following error:

Warning: No matches found for: fluxbox
No matches found

It’s sufficient to add EPEL (Extra Packages for Enterprise Linux) repository:

yum --enablerepo=extras install epel-release

Let’s test this whole setup on Docker image. We will install also TigerVNC server to view the Fluxbox UI:

docker run -p 5901:5901 -it centos /bin/bash
yum -y --enablerepo=extras install epel-release
yum install -y fluxbox tigervnc-server xterm
mkdir -p ~/.vnc
echo "fluxbox &"> ~/.vnc/xstartup
chmod u+x ~/.vnc/xstartup

Now connect by your VNC client (e.g. RealVNC) to localhost:5901. The result should look like this: