buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' } } allprojects { repositories { jcenter() } } apply plugin: 'com.android.application' dependencies { // android support libs compile 'com.android.support:support-v4:22.2.0' compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:cardview-v7:22.2.0' compile 'com.android.support:recyclerview-v7:22.2.0' compile 'com.android.support:design:22.2.0' // google play services compile 'com.google.android.gms:play-services-location:7.3.0' compile 'com.google.android.gms:play-services-analytics:7.3.0' compile 'com.google.android.gms:play-services-plus:7.3.0' // 3-party compile 'com.nineoldandroids:library:2.4.0' compile 'com.facebook.android:facebook-android-sdk:4.2.0' // for Parse SDK compile 'com.parse.bolts:bolts-android:1.+' compile fileTree(dir: '3rd_party', include: '*.jar', exclude: 'mrgsmanifest.jar') } def getDate() { def date = new Date() def formattedDate = date.format('yyMMdd') return formattedDate } android { // All properties are read from gradle.properties file compileSdkVersion propTargetSdkVersion.toInteger() buildToolsVersion propBuildToolsVersion defaultConfig { // Default package name is taken from the manifest and should be com.mapswithme.maps versionCode propVersionCode.toInteger() versionName propVersionName minSdkVersion propMinSdkVersion.toInteger() targetSdkVersion propTargetSdkVersion.toInteger() buildConfigField 'String', 'STATISTICS_URL', propStatisticsUrl } sourceSets.main { manifest.srcFile 'AndroidManifest.xml' res.srcDirs = ['res'] java.srcDirs = ['src', '../3party/Alohalytics/src/android/java'] // assets folder is auto-generated by tools/android/update_assets.sh, so we keep all static resources in separate folders. assets.srcDirs = ['assets', 'assets-mrgs'] jniLibs.srcDirs = ['libs'] } productFlavors { google { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-Google' buildConfigField 'String', 'REVIEW_URL', '"market://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"googleplay@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'false' } samsung { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-Samsung' buildConfigField 'String', 'REVIEW_URL', '"samsungapps://ProductDetail/com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"samsung@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'false' android.sourceSets.samsung.assets.srcDirs = ['flavors/mwm-ttf-assets'] } amazon { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-Amazon' buildConfigField 'String', 'REVIEW_URL', '"amzn://apps/android?p=com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"amazon@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'false' android.sourceSets.amazon.assets.srcDirs = ['flavors/mwm-ttf-assets'] } androidpit { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-AndroidPit' buildConfigField 'String', 'REVIEW_URL', '"appcenter://package/com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'false' android.sourceSets.androidpit.assets.srcDirs = ['flavors/mwm-ttf-assets'] } slideme { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-SlideMe' buildConfigField 'String', 'REVIEW_URL', '"sam://details?bundleId=5eed1b74-8c8b-11e2-8af8-1670ef61174f"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'false' android.sourceSets.slideme.assets.srcDirs = ['flavors/mwm-ttf-assets'] } yandex { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-Yandex' buildConfigField 'String', 'REVIEW_URL', '"yastore://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'false' android.sourceSets.yandex.assets.srcDirs = ['flavors/mwm-ttf-assets'] } prestigio { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-Prestigio' buildConfigField 'String', 'REVIEW_URL', '"market://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"googleplay@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'true' android.sourceSets.prestigio.assets.srcDirs = ['flavors/mwm-ttf-assets'] } cipherlab { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-CipherLab' buildConfigField 'String', 'REVIEW_URL', '"http://maps.me/"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'true' android.sourceSets.cipherlab.assets.srcDirs = ['flavors/mwm-ttf-assets'] } xiaomi { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-Xiaomi' buildConfigField 'String', 'REVIEW_URL', '"http://maps.me/"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'false' android.sourceSets.xiaomi.assets.srcDirs = ['flavors/mwm-ttf-assets'] } opera { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-Opera' buildConfigField 'String', 'REVIEW_URL', '"http://maps.me/"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'false' android.sourceSets.opera.assets.srcDirs = ['flavors/mwm-ttf-assets'] } lenovo { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-Lenovo' buildConfigField 'String', 'REVIEW_URL', '"market://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'true' android.sourceSets.lenovo.assets.srcDirs = ['flavors/mwm-ttf-assets'] } web { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-Web' buildConfigField 'String', 'REVIEW_URL', '"market://details?id=com.mapswithme.maps.pro"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'false' android.sourceSets.web.assets.srcDirs = ['flavors/mwm-ttf-assets'] } nineApp { applicationId 'com.mapswithme.maps.pro' versionName = android.defaultConfig.versionName + '-9app' buildConfigField 'String', 'REVIEW_URL', '"http://maps.me/"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"' buildConfigField 'boolean', 'IS_PREINSTALLED', 'false' android.sourceSets.nineApp.assets.srcDirs = ['flavors/mwm-ttf-assets'] } } // TODO: Fix a lot of lint errors in our code lintOptions { abortOnError false } // version at the end of each built apk applicationVariants.all { variant -> variant.outputs.each { output -> if (output.outputFile != null && output.outputFile.name.endsWith('.apk')) { def file = output.outputFile output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + "-" + getDate() + ".apk")) } } } gradle.projectsEvaluated { android.applicationVariants.all { variant -> def task = variant.name.capitalize() def runTask = "run$task" def installTask = "install$task" project.task(type: Exec, "${runTask}", dependsOn: "${installTask}") { def component = "$applicationId/com.mapswithme.maps.DownloadResourcesActivity" executable "sh" args "-c", "adb shell am start -n ${component}" } } } signingConfigs { mapswithme { storeFile file('../tools/android/mapswithme.keystore') storePassword '***REMOVED***' keyAlias 'mapswithme' keyPassword '***REMOVED***' } yopme { storeFile file('YopMe/key/android.keystore') storePassword '***REMOVED***' keyAlias 'yopme' keyPassword '***REMOVED***' } } buildTypes { debug { applicationIdSuffix '.debug' // Allows to install debug and release builds together versionNameSuffix '-debug' jniDebuggable true // Enable jni debug build zipAlignEnabled true android.sourceSets.debug.setRoot('flavors/debug') } release { signingConfig signingConfigs.mapswithme minifyEnabled true shrinkResources true proguardFile('proguard-mwm.txt') } beta { applicationIdSuffix '.beta' versionNameSuffix '-beta' signingConfig signingConfigs.mapswithme android.sourceSets.beta.setRoot('flavors/beta') } } // We don't compress these extensions in assets/ because our random FileReader can't read zip-compressed files from apk aaptOptions { noCompress 'txt', 'bin', 'skn', 'html', 'png', 'json', 'mwm', 'ttf' ignoreAssetsPattern "!.svn:!.git:!.DS_Store:!*.scc:.*:_*:!CVS:!thumbs.db:!picasa.ini:!*~" } // Enables new Java features in KitKat+ but needs Java 1.7 installed compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } } //@{ Below are tasks needed to compile our NDK part apply plugin: 'base' task cppLibsBuildDebug(type: Exec, description: 'Building DEBUG version of static C++ libraries') { commandLine 'bash', '../tools/autobuild/android.sh', 'debug' } task cppLibsBuildRelease(type: Exec, description: 'Building RELEASE/PRODUCTION version of static C++ libraries') { commandLine 'bash', '../tools/autobuild/android.sh', 'production' } def NUM_OF_PARALLEL_MAKE_TASKS = Runtime.runtime.availableProcessors() + 1 Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) def NDK_BUILD = properties.getProperty('ndk.dir') + '/ndk-build' task ndkBuildDebug(type: Exec, dependsOn: 'cppLibsBuildDebug', description: 'Building DEBUG jni sources') { def clArgs = ([NDK_BUILD, '-j' + NUM_OF_PARALLEL_MAKE_TASKS] + propDebugNdkFlags.split(' ')).flatten() commandLine clArgs } task ndkBuildRelease(type: Exec, dependsOn: 'cppLibsBuildRelease', description: 'Building RELEASE/PRODUCTION jni sources') { def clArgs = ([NDK_BUILD, '-j' + NUM_OF_PARALLEL_MAKE_TASKS] + propReleaseNdkFlags.split(' ')).flatten() commandLine clArgs } task ndkBuildClean(type: Exec, description: 'Clean native libraries') { commandLine NDK_BUILD, 'clean' } tasks.withType(JavaCompile) { compileTask -> if (compileTask.name.contains('Release') || compileTask.name.contains('Beta')) { compileTask.dependsOn ndkBuildRelease } else { compileTask.dependsOn ndkBuildDebug } } clean.dependsOn 'ndkBuildClean'