1 <#-- 2 Copyright 2013 The Android Open Source Project 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 --> 16 buildscript { 17 repositories { 18 jcenter() 19 } 20 21 dependencies { 22 classpath 'com.android.tools.build:gradle:2.3.2' 23 } 24 } 25 26 apply plugin: 'com.android.application' 27 28 repositories { 29 jcenter() 30 <#if sample.repository?has_content> 31 <#list sample.repository as rep> 32 ${rep} 33 </#list> 34 </#if> 35 } 36 37 dependencies { 38 <#if !sample.auto_add_support_lib?has_content || sample.auto_add_support_lib == "true"> 39 <#if sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 7> 40 compile "com.android.support:support-v4:25.3.1" 41 compile "com.android.support:appcompat-v7:25.3.1" 42 <#elseif sample.minSdk?matches(r'^\d+$') && sample.minSdk?number < 13> 43 compile "com.android.support:support-v4:25.3.1" 44 compile "com.android.support:gridlayout-v7:25.3.1" 45 compile "com.android.support:cardview-v7:25.3.1" 46 compile "com.android.support:appcompat-v7:25.3.1" 47 <#else> 48 compile "com.android.support:support-v4:25.3.1" 49 compile "com.android.support:support-v13:25.3.1" 50 compile "com.android.support:cardview-v7:25.3.1" 51 compile "com.android.support:appcompat-v7:25.3.1" 52 </#if> 53 </#if> 54 <#list sample.dependency as dep> 55 <#-- Output dependency after checking if it is a play services depdency and 56 needs the latest version number attached. --> 57 <@update_play_services_dependency dep="${dep}" /> 58 </#list> 59 <#list sample.dependency_external as dep> 60 compile files(${dep}) 61 </#list> 62 <#if sample.wearable.has_handheld_app?has_content && sample.wearable.has_handheld_app?lower_case == "true"> 63 compile ${play_services_wearable_dependency} 64 compile ${android_support_v13_dependency} 65 wearApp project(':Wearable') 66 </#if> 67 } 68 69 // The sample build uses multiple directories to 70 // keep boilerplate and common code separate from 71 // the main sample code. 72 List<String> dirs = [ 73 'main', // main sample code; look here for the interesting stuff. 74 'common', // components that are reused by multiple samples 75 'template'] // boilerplate code that is generated by the sample template process 76 77 android { 78 <#-- Note that target SDK is hardcoded in this template. We expect all samples 79 to always use the most current SDK as their target. --> 80 compileSdkVersion ${compile_sdk} 81 buildToolsVersion ${build_tools_version} 82 83 defaultConfig { 84 minSdkVersion ${min_sdk} 85 <#if sample.targetSdkVersion?? && sample.targetSdkVersion?has_content> 86 targetSdkVersion ${sample.targetSdkVersion} 87 <#else> 88 targetSdkVersion ${compile_sdk} 89 </#if> 90 } 91 92 compileOptions { 93 sourceCompatibility JavaVersion.VERSION_1_7 94 targetCompatibility JavaVersion.VERSION_1_7 95 } 96 97 sourceSets { 98 main { 99 dirs.each { dir -> 100 <#noparse> 101 java.srcDirs "src/${dir}/java" 102 res.srcDirs "src/${dir}/res" 103 </#noparse> 104 } 105 } 106 androidTest.setRoot('tests') 107 androidTest.java.srcDirs = ['tests/src'] 108 109 <#if sample.defaultConfig?has_content> 110 defaultConfig { 111 ${sample.defaultConfig} 112 } 113 <#else> 114 </#if> 115 } 116 117 <#if sample.aapt?has_content> 118 aaptOptions { 119 <#list sample.aapt.noCompress as noCompress> 120 noCompress "${noCompress}" 121 </#list> 122 } 123 </#if> 124 } 125