View on GitHub

keepass2android

Password manager app for Android

How to build Keepass2Android

Overview

Keepass2Android is a Mono for Android app. This means that you need Xamarin’s Mono for Android to build it. However, it also uses several components written in Java, so there are also Android-Studio projects involved. To make things even worse, parts of the keyboard and kdb-library are written in native code.

To build KP2A from scratch, you need:

Prior to building Keepass2Android, you need to build some of its components (from command line). Then you can build the full project either through Visual Studio, or through command line.

By using the command line, you can build on Windows, macOS or Linux.

Prerequisites

Common to all architectures

On Windows or macOS

On Linux

Building the required components:

This is done on the command line and requires the Android SDK & NDK and Java JDK.

On Windows

Notes:

On Linux/macOS

Building Keepass2Android:

These are the basic steps to build Keepass2Android. You can also build Keepass2Android Offline. For this, configure the build by using the Flavors.

With Visual Studio

Command Line

Windows, Macos & Linux

to build the APK, simply run:

    make

or to skip building the APK:

    make msbuild

Where is the APK ?

The Apk can be installed on a device. It is located in src/keepass2android/bin/*/*-Signed.apk

If you build with Visual Studio, the APK is not produced automatically. You need to perform some extra step. See the documentation of Visual Studio on how to proceed.

Flavors

Keepass2Android is distributed in two flavors.

The flavor is set through a MSBuild Property named “Flavor”. The possible values are ‘Net’ and ‘NoNet’.

The value of the Flavor property is used in 2 projects:

Its value is set inside the *.csproj file (XML format) of each project in the Project/PropertyGroup/Flavor node. By default its value is set to an empty string so that development is made with AndroidManifest_debug.xml on the ‘net’ flavor.

This is the behaviour of the build system depending on the value of Flavor: | Flavor | What is built | AndroidManifest.xml used | | —– | —– | —– | | `` (empty string): This is the default value. | Keepass2Android | AndroidManifest_debug.xml | | Net | Keepass2Android | AndroidManifest_net.xml | | NoNet | Keepass2Android Offline | AndroidManifest_nonet.xml |

Select/Change flavor:

When building, by default, the flavor is not set. So the value used is the value of the Flavor property in *.csproj file. This should result on doing a build of the ‘net’ flavor.

You can force the Flavor by setting the Flavor property.

Proceed this way:

Command line

Windows, Macos & Linux

To force building ‘net’ with make, run:

    make Flavor=Net

To build ‘nonet’ with make, run:

    make Flavor=NoNet
MSBuild

To build with MSBuild directly on the command line, set the flavor with -p:Flavor=value argument. For example:

    MSBuild src/KeePass.sln ... -p:Flavor=NoNet

Visual Studio

When building with Visual Studio, edit the *.csproj file (XML format) and set the value in the Project/PropertyGroup/Flavor node. This is needed only for the projects that use the flavors.

Note: When switching between flavors, be sure to clean the previous build before.

Makefile

It is possible to override the project’s default ‘Flavor’ (Net, NoNet) and ‘Configuration’ (Release, Debug) by passing it as argument to make. See the header of the Makefile to see what can be done.