У меня есть существующий проект, который успешно собирается с Java, gRPC (Protobuf) и Dagger2. Я хочу добавить Котлина в проект.
Я довольно легко преобразовал файлы данных в Kotlin. Когда я конвертировал первое действие (содержащее Dagger2), сборка не удалась. После добавления apply plugin: 'kotlin-kapt'
и нажатия кнопки «Синхронизировать» теперь отображается
Folder C:\AndroidStudioProjects\Bingo\app\build\generated\source\kaptKotlin\debug
Folder C:\AndroidStudioProjects\Bingo\app\build\generated\source\kaptKotlin\release
3rd-party Gradle plug-ins may be the cause
Сборка все равно не удалась, теперь она также не распознает файлы, созданные protobuf. * 1009 *
Кто-нибудь пробовал Котлин, Даггер, Протобуф вместе? Я не хочу полностью заменять Java на Kotlin.
Это мой файл уровня модуля:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.protobuf'
android {
compileSdkVersion 28
buildToolsVersion '28.0.0'
defaultConfig {
applicationId "com.productions.bingo"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
androidExtensions {
experimental = true
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.4.0'
}
plugins {
javalite {
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
}
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.8.0'
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
javalite {}
grpc {
// Options added to --grpc_out
option 'lite'
}
}
}
}
}
// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code.
sourceSets {
main.java.srcDirs += "${protobuf.generatedFilesBaseDir}/main/javalite"
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Butterknife
implementation 'com.jakewharton:butterknife:8.8.1'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
// Support Libraries
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
implementation 'com.android.support:preference-v7:28.0.0-alpha1'
implementation "com.android.support:support-core-utils:28.0.0-alpha1"
implementation 'com.android.support:cardview-v7:28.0.0-alpha1'
implementation 'com.android.support:customtabs:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
// gRPC
implementation 'io.grpc:grpc-okhttp:1.11.0'
implementation 'io.grpc:grpc-protobuf-lite:1.11.0'
implementation 'io.grpc:grpc-stub:1.11.0'
implementation 'javax.annotation:javax.annotation-api:1.2'
//Dagger
implementation 'com.google.dagger:dagger:2.13'
kapt "com.google.dagger:dagger-compiler:2.13"
implementation 'com.google.code.gson:gson:2.8.5'
// Celebration
implementation 'nl.dionsegijn:konfetti:1.1.2'
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.11.0'
implementation 'com.facebook.shimmer:shimmer:0.2.0'
// Testing-only dependencies
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support:support-annotations:27.1.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
testImplementation 'junit:junit:4.12'
// Kotlin libraries
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.anko:anko:0.10.5"
}
Это файл проекта моего проекта:
buildscript {
ext.kotlin_version = '1.2.50'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.1.1'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}