Created
January 11, 2017 09:32
-
-
Save roxxydev/aa413a0a705164fde093765ebe7b3c5b to your computer and use it in GitHub Desktop.
android-project-gradle-circleci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'com.android.application' | |
| repositories { | |
| maven { url "https://jitpack.io" } | |
| maven { url 'https://maven.fabric.io/public' } | |
| } | |
| // Production version | |
| def versionMajor = 1; | |
| def versionMinor = 0; | |
| def versionPatch = 0; | |
| // Staging version | |
| def stagingVersionMajor = 1; | |
| def stagingVersionMinor = 0; | |
| def stagingVersionPatch = 0; | |
| // Dev version | |
| def devVersionMajor = 1; | |
| def devVersionMinor = 0; | |
| def devVersionPatch = 0; | |
| def crashlyticsEnabled = false | |
| android { | |
| signingConfigs { | |
| release { | |
| keyAlias 'your-key-alias' | |
| keyPassword 'your-key-password' | |
| storeFile file('../yourKeystoreFilename.jks') // under root project directory | |
| storePassword 'your-keystore-password' | |
| } | |
| } | |
| compileSdkVersion 24 | |
| buildToolsVersion '24.0.3' | |
| defaultConfig { | |
| applicationId "com.sampleandroid.sample" | |
| minSdkVersion 19 | |
| targetSdkVersion 24 | |
| versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch | |
| versionName "${versionMajor}.${versionMinor}.${versionPatch}" | |
| multiDexEnabled true | |
| testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' | |
| } | |
| buildTypes { | |
| debug { | |
| minifyEnabled false | |
| shrinkResources false | |
| } | |
| release { | |
| debuggable false | |
| minifyEnabled false | |
| proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
| signingConfig signingConfigs.release | |
| } | |
| // Rename generated APK build based on app name, version name, and buildType | |
| applicationVariants.all { variant -> | |
| variant.outputs.each { output -> | |
| def build_name = "Debug"; | |
| if (variant.buildType.name == "debug") | |
| build_name = "Debug" | |
| else if (variant.buildType.name == "release") | |
| build_name = "Release" | |
| def variant_name = variant.productFlavors[0].name; | |
| def apk_name = "YourDesireApkName";// Project name | |
| def finalName = apk_name + "_" + variant.versionName + "_" + variant_name + build_name + ".apk"; | |
| output.outputFile = new File(output.outputFile.parent, finalName) | |
| } | |
| } | |
| } | |
| productFlavors { | |
| dev { | |
| applicationId "com.sampleandroid.dev" | |
| versionCode devVersionMajor * 10000 + devVersionMinor * 100 + devVersionPatch | |
| versionName "${devVersionMajor}.${devVersionMinor}.${devVersionPatch}" | |
| buildConfigField "String", "API_ENDPOINT", "\"http://develop.api.com/\"" | |
| resValue "string", "app_name", "Sample Dev" | |
| resValue 'string', 'maps_v2_api_key', 'your-google-maps-api-key' | |
| // Disable fabric build ID generation for debug builds | |
| buildConfigField "boolean", "IS_CRASHLYTICS_ENABLED", crashlyticsEnabled.toString() | |
| ext.enableCrashlytics = crashlyticsEnabled | |
| // Google Places API key should also match with the maps_v2_api_key | |
| buildConfigField "String", "GOOGLE_PLACES_API_KEY", "\"your-google-maps-api-key\"" | |
| // Fabric release notes | |
| ext.betaDistributionReleaseNotesFilePath="release_notes_dev.txt" | |
| ext.betaDistributionEmailsFilePath="tester_emails.txt" // tester emails in comma-seperated | |
| } | |
| staging { | |
| applicationId "com.sampleandroid.staging" | |
| versionCode devVersionMajor * 10000 + devVersionMinor * 100 + devVersionPatch | |
| versionName "${devVersionMajor}.${devVersionMinor}.${devVersionPatch}" | |
| buildConfigField "String", "API_ENDPOINT", "\"http://staging.api.com/\"" | |
| resValue "string", "app_name", "Sample Staging" | |
| resValue 'string', 'maps_v2_api_key', 'your-google-maps-api-key' | |
| buildConfigField "boolean", "IS_CRASHLYTICS_ENABLED", crashlyticsEnabled.toString() | |
| ext.enableCrashlytics = crashlyticsEnabled | |
| buildConfigField "String", "GOOGLE_PLACES_API_KEY", "\"your-google-maps-api-key\"" | |
| ext.betaDistributionReleaseNotesFilePath="release_notes_staging.txt" | |
| ext.betaDistributionEmailsFilePath="tester_emails.txt" | |
| } | |
| production { | |
| buildConfigField "String", "API_ENDPOINT", "\"https://prod.api.com/\"" | |
| buildConfigField "String", "CLIENT_ID", "\"JDJhJDEyJFJqWklZeTdDeVBDemdBOTkxUUN4c3U=\"" | |
| resValue "string", "app_name", "Sample" | |
| resValue 'string', 'maps_v2_api_key', 'your-google-maps-api-key' | |
| // Set to false when building apk for Google Play | |
| crashlyticsEnabled = true | |
| buildConfigField "boolean", "IS_CRASHLYTICS_ENABLED", crashlyticsEnabled.toString() | |
| ext.enableCrashlytics = crashlyticsEnabled | |
| buildConfigField "String", "GOOGLE_PLACES_API_KEY", "\"your-google-maps-api-key\"" | |
| ext.betaDistributionReleaseNotesFilePath="release_notes_production.txt" | |
| ext.betaDistributionEmailsFilePath="tester_emails.txt" | |
| } | |
| } | |
| lintOptions { | |
| abortOnError false | |
| } | |
| compileOptions { | |
| sourceCompatibility JavaVersion.VERSION_1_7 | |
| targetCompatibility JavaVersion.VERSION_1_7 | |
| } | |
| } | |
| buildscript { | |
| repositories { | |
| mavenCentral() | |
| maven { url 'https://maven.fabric.io/public' } | |
| } | |
| dependencies { | |
| classpath 'io.fabric.tools:gradle:1.+' | |
| } | |
| } | |
| dependencies { | |
| Map<String, String> dependencies = rootProject.ext.dependencies; | |
| compile dependencies.design | |
| compile dependencies.appCompat | |
| compile dependencies.recyclerView | |
| compile dependencies.glide | |
| compile dependencies.rxJava | |
| compile dependencies.rxAndroid | |
| apt dependencies.daggerCompiler | |
| compile dependencies.dagger | |
| provided dependencies.javaxAnnotation | |
| compile dependencies.butterKnife | |
| apt dependencies.butterKnifeCompiler | |
| compile dependencies.googleMaps | |
| compile dependencies.googleLocation | |
| compile dependencies.timber | |
| compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') { | |
| transitive = true; | |
| } | |
| testCompile dependencies.jUnit | |
| androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') { | |
| exclude group: 'com.android.support', module: 'support-v4' | |
| exclude group: 'com.android.support', module: 'support-annotations' | |
| exclude group: 'javax.inject' | |
| } | |
| androidTestCompile('com.android.support.test:runner:0.5') { | |
| exclude group: 'com.android.support', module: 'support-v4' | |
| exclude group: 'com.android.support', module: 'support-annotations' | |
| exclude group: 'javax.inject' | |
| } | |
| debugCompile dependencies.leakCanaryDebug | |
| releaseCompile dependencies.leakCanaryRelease | |
| } | |
| apply plugin: 'com.google.gms.google-services' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ext { | |
| // Libraries | |
| supportLibraryVersion = '25.0.0' | |
| playServicesVersion = '9.2.1' | |
| daggerVersion = '2.0' | |
| rxJavaVersion = '1.1.6' | |
| rxAndroidVersion = '1.2.1' | |
| butterknifeVersion = '8.1.0' | |
| javaxAnnotationVersion = '1.0' | |
| glideVersion = '3.7.0' | |
| leakCanaryVersion = '1.4' | |
| // Testing | |
| jUnitVersion = '4.12' | |
| dependencies = [ | |
| // Support Libraries | |
| appCompat : "com.android.support:appcompat-v7:${supportLibraryVersion}", | |
| design : "com.android.support:design:${supportLibraryVersion}", | |
| recyclerView : "com.android.support:recyclerview-v7:${supportLibraryVersion}", | |
| card : "com.android.support:cardview-v7:${supportLibraryVersion}", | |
| annotations : "com.android.support:support-annotations:${supportLibraryVersion}", | |
| googleLocation : "com.google.android.gms:play-services-location:${playServicesVersion}", | |
| googleMaps : "com.google.android.gms:play-services-maps:${playServicesVersion}", | |
| // Dagger | |
| daggerCompiler : "com.google.dagger:dagger-compiler:${daggerVersion}", | |
| dagger : "com.google.dagger:dagger:${daggerVersion}", | |
| // Butterknife | |
| butterKnife : "com.jakewharton:butterknife:${butterknifeVersion}", | |
| butterKnifeCompiler : "com.jakewharton:butterknife-compiler:${butterknifeVersion}", | |
| // RxJava | |
| rxJava : "io.reactivex:rxjava:${rxJavaVersion}", | |
| rxAndroid : "io.reactivex:rxandroid:${rxAndroidVersion}", | |
| javaxAnnotation : "javax.annotation:jsr250-api:${javaxAnnotationVersion}", | |
| // Utilities | |
| glide : "com.github.bumptech.glide:glide:${glideVersion}", | |
| timber : "com.jakewharton.timber:timber:4.1.2", | |
| // Testing | |
| jUnit : "junit:junit:$jUnitVersion", | |
| espresso : "com.android.support.test.espresso:espresso-core:2.2.2", | |
| testRunner : "com.android.support.test:runner:0.5", | |
| testRules : "com.android.support.test:rules:0.5" | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Build configuration for Circle CI | |
| # | |
| general: | |
| branches: | |
| only: | |
| - master | |
| - develop | |
| artifacts: | |
| - /home/ubuntu/<your-project-name>/app/build/outputs/apk/ | |
| machine: | |
| java: | |
| version: oraclejdk8 | |
| environment: | |
| ANDROID_HOME: /usr/local/android-sdk-linux | |
| GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx3072M -XX:+HeapDumpOnOutOfMemoryError"' | |
| dependencies: | |
| pre: | |
| - chmod +x gradlew | |
| - echo y | android update sdk --no-ui --all --filter "tools,android-24,build-tools-24.0.3,platform-tools,extra-android-m2repository,extra-android-support,extra-google-m2repository,extra-google-google_play_services" | |
| cache_directories: | |
| - /usr/local/android-sdk-linux/tools | |
| - /usr/local/android-sdk-linux/build-tools/24.0.3 | |
| test: | |
| override: | |
| - ./gradlew assembleDevDebug | |
| - ./gradlew assembleStagingDebug | |
| - ./gradlew assembleProductionDebug | |
| post: | |
| - cp -r /home/ubuntu/<your-project-name>/app/build/outputs $CIRCLE_ARTIFACTS | |
| deployment: | |
| develop: | |
| branch: develop | |
| commands: | |
| - ./gradlew crashlyticsUploadDistributionDevDebug | |
| production: | |
| branch: master | |
| commands: | |
| - ./gradlew crashlyticsUploadDistributionStagingDebug | |
| - ./gradlew crashlyticsUploadDistributionProductionDebug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply from: 'dependencies.gradle' | |
| buildscript { | |
| repositories { | |
| jcenter() | |
| } | |
| dependencies { | |
| classpath 'com.android.tools.build:gradle:2.2.0' | |
| classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' | |
| classpath 'com.google.gms:google-services:3.0.0' | |
| classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.6' | |
| } | |
| } | |
| allprojects { | |
| repositories { | |
| jcenter() | |
| } | |
| } | |
| task clean(type: Delete) { | |
| delete rootProject.buildDir | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment