CoF FOSS Repo

CoF FOSS Repo
Login

Building and installing the app

This document describes steps to create a Docker image for building a signed APK of the app.

Docker and Fossil

install Docker-CE for Mac, Ubuntu or whatever works for you.

install Fossil

get familiar with the Fossil workflow

have a look at the Fossil commands

clone CoF repository to a location of your choice, here repos/CoF.fossil:
fossil clone https://www.chainsoffreedom.org/cgi-bin/apprepo.sh repos/CoF.fossil

change to the directory where you want the CoF sources and open the repository, like so:
mkdir CoF ; cd CoF
fossil open ../repos/CoF.fossil

if your user in the remote fossil repository has sufficient rights to push locally commited changes, you can configure your remote-url with the credentials:

fossil remote-url https://username:password@www.chainsoffreedom.org/cgi-bin/apprepo.sh

Special characters in the password might cause problems!

install React-Native Docker image following process of Luke Mayhew:

cd react-native-app
// mind the dot at the end of next line!
docker build -t react-native-image .
go get coffee // no seriously

add helper script rn to your PATH:
cd ../bin
./addcurrentdirtobashpath
source ~/.profile

build signed app for Android

setting up the container to build a signed release version of the app:

create keystore for signing your APK:

cd ~
mkdir keystore ; cd keystore
keytool -genkey -v -keystore CoF-release-key.keystore -alias CoF-key-alias -keyalg RSA -keysize 2048 -validity 10000

add to ~/.rngradle/gradle.properties and fill in your passwords:
COFAPP_RELEASE_STORE_FILE=/keystore/CoF-release-key.keystore
COFAPP_RELEASE_KEY_ALIAS=CoF-key-alias
COFAPP_RELEASE_STORE_PASSWORD=
COFAPP_RELEASE_KEY_PASSWORD=

insert keystore credentials into gradle build system

this is already in the build.gradle in the repository. skip it.

cd react-native-app/CoFApp

add to android/app/build.gradle:
...
android {
...
defaultConfig { ... }
signingConfigs {
release {
if (project.hasProperty('COFAPP_RELEASE_STORE_FILE')) {
storeFile file(COFAPP_RELEASE_STORE_FILE)
storePassword COFAPP_RELEASE_STORE_PASSWORD
keyAlias COFAPP_RELEASE_KEY_ALIAS
keyPassword COFAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}
}
...

create softlink to gradle.properties and asset directory

make sure the assets dir exists:
mkdir android/app/src/main/assets

The environment variable GRADLE_USER_HOME points to /project/android/gradle_deps instead of the default ~/.gradle where our gradle.properties resides. We need to make a symbolic link to the properties file:
ln -s /home/dev/.gradle/gradle.properties /project/android/gradle_deps

build and install on android phone

rn bash
from now in the React-Native Docker container..

go to project folder and run yarn:
yarn
react-native link

go to android folder

./gradlew assembleRelease

exit
exiting the React Native Docker container.

make sure usb debugging and installation of apps by usb is activated on phone

go to CofApp directory
check if your android device is found by adb with
adb devices
install the signed apk with
adb install -r ./android/app/build/outputs/apk/release/app-release.apk