Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Commit

Permalink
fix: Build gradle wrapper
Browse files Browse the repository at this point in the history
Add Gradle Apk signing.
  • Loading branch information
aoudiamoncef committed May 6, 2018
1 parent 0261411 commit 9bd4b45
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 39 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ before_install:
- mv ${TRAVIS_BUILD_DIR}/google-services.json ${TRAVIS_BUILD_DIR}/app/google-services.json
- cp local.properties.ci local.properties
- ls -all
- source scripts/writeToManifest.sh && copyEnvVarsToManifest
- source scripts/writeEnvVariables.sh.sh && copyEnvVarsToManifest && copyEnvVarsToSigningProperties
- docker pull influxdb
- docker run --name=influxdb -d -p 127.0.0.1:8086:8086 influxdb
- docker ps -a
Expand All @@ -48,13 +48,12 @@ android:
script:
- android list target
- curl -i -XPOST http://127.0.0.1:8086/query --data-urlencode "q=CREATE DATABASE test"
- "./gradlew clean test build"
- ./gradlew clean test build
before_deploy:
- cd app/build/outputs/apk/release
- jarsigner -verbose -tsa http://timestamp.comodoca.com/rfc3161 -sigalg SHA1withRSA -digestalg SHA1 -keystore ${TRAVIS_BUILD_DIR}/ApollineKeystore.jks -storepass $STOREPASS -keypass $KEYPASS app-release-unsigned.apk $ALIAS
- jarsigner -verbose -tsa http://timestamp.comodoca.com/rfc3161 -sigalg SHA1withRSA -digestalg SHA1 -keystore ${TRAVIS_BUILD_DIR}/ApollineKeystore.jks -storepass $STORE_PASSWORD -keypass $KEY_PASSWORD app-release-unsigned.apk $KEY_ALIAS
- jarsigner -verify app-release-unsigned.apk
- "${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS}/zipalign -v 4 app-release-unsigned.apk
Apolline.apk"
- ${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS}/zipalign -v 4 app-release-unsigned.apk Apolline.apk
deploy:
provider: releases
skip_cleanup: true
Expand Down
50 changes: 33 additions & 17 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'jacoco'
apply plugin: 'com.akaita.android.easylauncher'

def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {

Expand All @@ -24,6 +27,9 @@ android {
minSdkVersion 21
targetSdkVersion 27

versionCode 17
versionName "2.4.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
Expand All @@ -33,8 +39,17 @@ android {
multiDexEnabled true
}

buildTypes {

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}

buildTypes {

debug {
Properties properties = new Properties()
Expand All @@ -57,16 +72,17 @@ android {

buildConfigField 'boolean', 'ENABLE_CRASHLYTICS', 'true'
minifyEnabled false
// shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

signingConfig signingConfigs.release
}

}

// implementationOptions {
// targetCompatibility 1.8
// sourceCompatibility 1.8
// }
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}

testOptions {

Expand All @@ -93,16 +109,17 @@ android {
multiDexEnabled true
}

// Ensure the no-op dependency is always used in JVM tests.
configurations.all { config ->
if (config.name.contains('UnitTest')) {
config.resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.squareup.leakcanary' && details.requested.name == 'leakcanary-android') {
details.useTarget(group: details.requested.group, name: 'leakcanary-android-no-op', version: details.requested.version)
}
}
}
}
// flavorDimensions 'tier'
// productFlavors {
// development {
// dimension 'tier'
// applicationId "science.apolline"
// }
// production {
// dimension 'tier'
// applicationId "science.apolline"
// }
// }

}

Expand Down Expand Up @@ -284,7 +301,6 @@ configurations {
}



jacoco {
toolVersion = "$jacoco_version"
reportsDir = file("$buildDir/reports")
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="science.apolline"
android:versionCode="17"
android:versionName="2.4.0">
package="science.apolline">

<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
fabric_version = '1.25.1'
gmss_version = '3.1.1'
firebase_version = '1.1.5'
easylauncher = '1.1.0'
easylauncher_version = '1.1.0'
sonarqube_url = hasProperty('SONARQUBE_URL') ? SONARQUBE_URL : System.getenv('SONARQUBE_URL')
}
repositories {
Expand All @@ -20,14 +20,14 @@ buildscript {
}
dependencies {

classpath "com.android.tools.build:gradle:$gradle_version"
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.fabric.tools:gradle:$fabric_version"
classpath "com.google.gms:google-services:$gmss_version"
classpath "com.google.firebase:firebase-plugins:$firebase_version"
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:$sonarqube_version"
classpath "com.akaita.android:easylauncher:$easylauncher"
classpath "com.akaita.android:easylauncher:$easylauncher_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
4 changes: 4 additions & 0 deletions keystore.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
storePassword=myStorePassword
keyPassword=mykeyPassword
keyAlias=myKeyAlias
storeFile=ApollineKeystore.jks
22 changes: 22 additions & 0 deletions scripts/writeEnvVariables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

function copyEnvVarsToManifest {
ANDROID_MANIFEST=${TRAVIS_BUILD_DIR}"/app/src/main/AndroidManifest.xml"

export ANDROID_MANIFEST
echo "AndroidManifest should exist at $ANDROID_MANIFEST"
sed -i -e "s/\"\${google_map_api_key}\"/"\"$GOOGLE_MAP_API_KEY\""/g" $ANDROID_MANIFEST
sed -i -e "s/\"\${fabric_api_key}\"/"\"$FABRIC_API_KEY\""/g" $ANDROID_MANIFEST
}

function copyEnvVarsToSigningProperties {
KEYSTORE_AUTH=${TRAVIS_BUILD_DIR}"/keystore.properties"

export KEYSTORE_AUTH
echo "keystore.properties should exist at $KEYSTORE_AUTH"
sed -i -e "s/myStorePassword/'"$STORE_PASSWORD"'/g" $KEYSTORE_AUTH
sed -i -e "s/mykeyPassword/'"$KEY_PASSWORD"'/g" $KEYSTORE_AUTH
sed -i -e "s/myKeyAlias/'"$KEY_ALIAS"'/g" $KEYSTORE_AUTH
sed -i -e "s/storeFile/'"$STORE_FILE"'/g" $KEYSTORE_AUTH

}
10 changes: 0 additions & 10 deletions scripts/writeToManifest.sh

This file was deleted.

0 comments on commit 9bd4b45

Please sign in to comment.