Skip to content

How to build Signal from the sources

Andrew Emil edited this page Aug 11, 2021 · 12 revisions

See also https://github.com/signalapp/Signal-Android/tree/master/reproducible-builds

The following information concentrates on compiling on LINUX, OS X or Windows machines. If you can and want to contribute information how to compile on other platforms: you are welcome to add such infos.

Prerequisites

  • "Android SDK manager"
  • "Android Support Repository" - this need to be installed via the Android SDK manager
  • "Java Development Kit (JDK)" compiler for example openjdk-devel - JRE alone is not enough. Use Java 8, as defined in the Gradle config.
  • "Git for Windows" - If you are running Windows, you will need git (https://git-scm.com/download/win) installed for this tutorial.

LINUX or OS X

Build Signal (for experts who have all the prerequisites)

# assuming your working directory is /work
cd /work
git clone https://github.com/signalapp/Signal-Android.git Signal-Android
cd Signal-Android
# execute Gradle
./gradlew build
# If you see "BUILD SUCCESSFUL" then fetch and install your apk
/work/Signal-Android/build/outputs/apk/Signal-Android-debug-unaligned.apk
# cleaning up
./gradlew clean

Build Signal (detailed, for newbies)

# assuming the project working directory is /work
cd /work
git clone https://github.com/signalapp/Signal-Android.git Signal-Android

# as a developer
# you would clone using the git protocol and your username
# git clone [email protected]:Username/Signal-Android.git Signal-Android

cd Signal-Android

# install Gradle (if is not installed yet) and then execute Gradle
./gradlew build

# if you see an error message
#
# "SDK location not found. Define location with sdk.dir in the local.properties file
# or with an ANDROID_HOME environment variable" ...
#
# ... then download and unzip the Android "ADT Bundle" or "SDK Tools only"
# from http://developer.android.com/sdk/index.html
#
# ... create a file /work/Signal-Android/local.properties which points to the sdk subdirectory
# which you unzipped in the previous step
# sdk.dir=<path-to-your>/sdk

# retry the build
./gradlew build

# when you see "Could not find com.android.support:support-v" ...
# ... you have also forgotten to install the support library
# see http://developer.android.com/tools/support-library/setup.html for different methods to install 
# that library, for example you can run "<path-to-your>/sdk/tools/android sdk"

# retry the build
./gradlew build

# when you see "Cannot find System Java Compiler ...." ...
# ... you have also forgotten to install an JAVA compiler (a Java Runtime Environment JRE is not enough)
# then install openjdk-devel for your distribution

# retry the build
./gradlew build

# when you see "Could not resolve all dependencies for configuration ':_debugCompile'.
#   > Could not find com.android.support:support-v4:19.0.1."
# ... you have the wrong Android SDK Build Tools installed.
# see http://developer.android.com/tools/support-library/setup.html for different methods to install 
# that library, for example you can run "<path-to-your>/sdk/tools/android sdk"
# and add the version mentioned in the error message, here: 19.0.1

# retry the build
./gradlew build

# If you see "You have not accepted the license agreements of the following SDK components:" ...
# ... you do not have the proper Android Build Tools installed. Look for the version number it needs
# (it should say right under that last error line) and install the build-tools version corresponding
# to that number.

# retry the build
./gradlew build

# If you see "BUILD SUCCESSFUL" then locate your apks as
/work/Signal-Android/build/outputs/apk/Signal-Android-debug-unaligned.apk and
/work/Signal-Android/build/outputs/apk/Signal-Android-release-unsigned.apk

# If you wish to install the release build, it needs to be signed: https://developer.android.com/tools/publishing/app-signing.html

# A quick and dirty method is:

cd build/outputs/apk
keytool -genkey -v -keystore example.keystore -alias SomeAlias -keyalg RSA -keysize 4096
jarsigner -verbose -keystore example.keystore Signal-Android-release-unsigned.apk SomeAlias

# You can now use 'Signal-Android-release-unsigned.apk' and/or rename it to what you like.
# cleaning up
./gradlew clean

WINDOWS

Build Signal (for experts who have all the prerequisites)

# assuming your working directory is c:\work
cd c:\work
git clone https://github.com/WhisperSystems/Signal-Android.git Signal-Android
cd Signal-Android
# execute Gradle
gradlew.bat build
# If you see "BUILD SUCCESSFUL" then fetch and install your apk
c:\work\Signal-Android\build\outputs\apk\Signal-website-debug-*.apk
# cleaning up
gradlew.bat clean