1apply plugin: 'com.android.application' 2apply plugin: 'kotlin-android' 3apply plugin: 'kotlin-android-extensions' 4apply plugin: 'com.google.protobuf' 5 6android { 7 compileSdkVersion 27 8 9 defaultConfig { 10 applicationId "io.grpc.helloworldexample" 11 // API level 14+ is required for TLS since Google Play Services v10.2 12 minSdkVersion 14 13 targetSdkVersion 27 14 versionCode 1 15 versionName "1.0" 16 } 17 buildTypes { 18 debug { minifyEnabled false } 19 release { 20 minifyEnabled true 21 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 } 23 } 24 lintOptions { 25 disable 'GoogleAppIndexingWarning', 'HardcodedText', 'InvalidPackage' 26 textReport true 27 textOutput "stdout" 28 } 29 // Android Studio 3.1 does not automatically pick up '<src_set>/kotlin' as source input 30 sourceSets { 31 main.java.srcDirs += 'src/main/kotlin' 32 test.java.srcDirs += 'src/test/kotlin' 33 androidTest.java.srcDirs += 'src/androidTest/kotlin' 34 } 35 36 lintOptions { 37 // Do not complain about outdated deps, so that this can javax.annotation-api can be same 38 // as other projects in this repo. Your project is not required to do this, and can 39 // upgrade the dep. 40 disable 'GradleDependency' 41 // The Android linter does not correctly detect resources used in Kotlin. 42 // See: 43 // - https://youtrack.jetbrains.com/issue/KT-7729 44 // - https://youtrack.jetbrains.com/issue/KT-12499 45 disable 'UnusedResources' 46 textReport true 47 textOutput "stdout" 48 } 49} 50 51protobuf { 52 protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' } 53 plugins { 54 javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" } 55 grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.16.0-SNAPSHOT' // CURRENT_GRPC_VERSION 56 } 57 } 58 generateProtoTasks { 59 all().each { task -> 60 task.plugins { 61 javalite {} 62 grpc { // Options added to --grpc_out 63 option 'lite' } 64 } 65 } 66 } 67} 68 69dependencies { 70 compile 'com.android.support:appcompat-v7:27.0.2' 71 compile 'javax.annotation:javax.annotation-api:1.2' 72 compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 73 74 // You need to build grpc-java to obtain these libraries below. 75 compile 'io.grpc:grpc-okhttp:1.16.0-SNAPSHOT' // CURRENT_GRPC_VERSION 76 compile 'io.grpc:grpc-protobuf-lite:1.16.0-SNAPSHOT' // CURRENT_GRPC_VERSION 77 compile 'io.grpc:grpc-stub:1.16.0-SNAPSHOT' // CURRENT_GRPC_VERSION 78} 79 80repositories { mavenCentral() } 81