Skip to content

How to build Signal from the sources

agrajaghh edited this page Jan 1, 2016 · 12 revisions

See also https://github.com/WhisperSystems/Signal-Android/blob/master/BUILDING.md

The following information concentrates on compiling on LINUX or OS X 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. At least version 7 of Java is required.

Build Signal (for experts who have all the prerequisites)

# assuming your working directory is /work
cd /work
git clone https://github.com/WhisperSystems/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/WhisperSystems/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 TextSecure

# 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 "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 TextSecure-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