From e35db564055a628c9a625d06be5850b8e46f0730 Mon Sep 17 00:00:00 2001 From: mpl Date: Tue, 24 Apr 2018 16:10:05 -0700 Subject: [PATCH] clients/android: add steps to sign the apk Change-Id: I776dd14efca4bd10263a7c7422e0ffd5c706a523 --- clients/android/Makefile | 10 ++++++---- clients/android/app/build.gradle | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/clients/android/Makefile b/clients/android/Makefile index c2e918859..20dce852e 100644 --- a/clients/android/Makefile +++ b/clients/android/Makefile @@ -10,13 +10,16 @@ env: docker build -t perkeep/android devenv dockerdev: - docker run --rm -v $(GOPATH)/src/perkeep.org:/home/gopher/src/perkeep.org -v $(HOME)/.gradle:/home/gopher/.gradle -v $(HOME)/.android:/home/gopher/.android -w /home/gopher/src/perkeep.org/clients/android --name camlidroid -i -t perkeep/android /bin/bash + docker run --rm -v $(GOPATH)/src/perkeep.org:/home/gopher/src/perkeep.org -v $(HOME)/.gradle:/home/gopher/.gradle -v $(HOME)/.android:/home/gopher/.android -v $(HOME)/keys:/keys -w /home/gopher/src/perkeep.org/clients/android --name camlidroid -i -t perkeep/android /bin/bash dockerdebug: docker run --rm -v $(GOPATH)/src/perkeep.org:/home/gopher/src/perkeep.org -v $(HOME)/.gradle:/home/gopher/.gradle -v $(HOME)/.android:/home/gopher/.android -w /home/gopher/src/perkeep.org/clients/android --name camlidroid -i -t perkeep/android go run build-in-docker.go dockerrelease: - docker run --rm -v $(GOPATH)/src/perkeep.org:/home/gopher/src/perkeep.org -v $(HOME)/.gradle:/home/gopher/.gradle -v $(HOME)/.android:/home/gopher/.android -w /home/gopher/src/perkeep.org/clients/android --name camlidroid -i -t perkeep/android go run build-in-docker.go -release=true + docker run --rm -v $(GOPATH)/src/perkeep.org:/home/gopher/src/perkeep.org -v $(HOME)/.gradle:/home/gopher/.gradle -v $(HOME)/.android:/home/gopher/.android -v $(HOME)/keys:/keys -w /home/gopher/src/perkeep.org/clients/android --name camlidroid -i -t perkeep/android go run build-in-docker.go -release=true + +dockersignrelease: + docker run --rm -v $(GOPATH)/src/perkeep.org:/home/gopher/src/perkeep.org -v $(HOME)/.gradle:/home/gopher/.gradle -v $(HOME)/.android:/home/gopher/.android -v $(HOME)/keys:/keys -w /home/gopher/src/perkeep.org/clients/android --name camlidroid -i -t perkeep/android /home/gopher/android-sdk/build-tools/27.0.0/apksigner sign --ks /keys/perkeep-android.keystore --out ./app/build/outputs/apk/release/app-release.apk ./app/build/outputs/apk/release/app-release-unsigned.apk # just for documentation, as make is not actually installed in the docker image. debug: @@ -27,8 +30,7 @@ installdebug: adb install -r app/build/outputs/apk/debug/app-debug.apk install: - # TODO(bradfitz): step to sign app/build/outputs/apk/app-release-unsigned.apk - # adb install -r app/build/outputs/apk/app-release.apk + adb install -r app/build/outputs/apk/release/app-release.apk test: # TODO(mpl): can't run the instrumentation tests within docker, since diff --git a/clients/android/app/build.gradle b/clients/android/app/build.gradle index d77f6135c..736dec32d 100644 --- a/clients/android/app/build.gradle +++ b/clients/android/app/build.gradle @@ -5,9 +5,30 @@ */ apply plugin: 'com.android.application' +// Create a variable called keystorePropertiesFile, and initialize it to your +// keystore.properties file, in the rootProject folder. +def keystorePropertiesFile = rootProject.file("keystore.properties") + +// Initialize a new Properties() object called keystoreProperties. +def keystoreProperties = new Properties() + +// Load your keystore.properties file into the keystoreProperties object. +keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) + android { compileSdkVersion 27 + // TODO(mpl): this should make signing the apk automatic when building the + // release flavor, but it does not seem to. figure out why. use Makefile in the + // meantime. + signingConfigs { + config { + keyAlias keystoreProperties['keyAlias'] + storeFile file(keystoreProperties['storeFile']) + storePassword keystoreProperties['storePassword'] + } + } + defaultConfig { applicationId "org.camlistore" minSdkVersion 14