Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error or misconfiguration? #380

Closed
HDNAdministrator opened this issue Feb 10, 2023 · 3 comments
Closed

Error or misconfiguration? #380

HDNAdministrator opened this issue Feb 10, 2023 · 3 comments

Comments

@HDNAdministrator
Copy link

I'm getting the error bellow after following the kotlin example

The task 'compileDebugAndroidTestKotlin' (org.jetbrains.kotlin.gradle.tasks.KotlinCompile) is not a subclass of the given type (org.gradle.api.tasks.SourceTask).
The task 'compileDebugUnitTestKotlin' (org.jetbrains.kotlin.gradle.tasks.KotlinCompile) is not a subclass of the given type (org.gradle.api.tasks.SourceTask).
The task 'compileDebugKotlin' (org.jetbrains.kotlin.gradle.tasks.KotlinCompile) is not a subclass of the given type (org.gradle.api.tasks.SourceTask).
The task 'compileReleaseUnitTestKotlin' (org.jetbrains.kotlin.gradle.tasks.KotlinCompile) is not a subclass of the given type (org.gradle.api.tasks.SourceTask).
The task 'compileReleaseKotlin' (org.jetbrains.kotlin.gradle.tasks.KotlinCompile) is not a subclass of the given type (org.gradle.api.tasks.SourceTask).

Config

Gradle 7.6

master build.gradle

plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
id 'com.google.protobuf' version '0.9.2' apply false
}

module build.grade

plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'com.google.protobuf'
}

android {
...
}

dependencies {
protobuf(rootProject.ext.protos.grpc)
implementation rootProject.ext.libs.grpc.kotlinStub
implementation rootProject.ext.libs.grpc.okHttp
implementation rootProject.ext.libs.grpc.protobuf
implementation rootProject.ext.libs.grpc.stub
implementation rootProject.ext.libs.protobuf.protobuf
testImplementation rootProject.ext.libs.junit
testImplementation rootProject.ext.libs.mockk
testImplementation rootProject.ext.libs.truth
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
sourceCompatibility = rootProject.ext.java
targetCompatibility = rootProject.ext.java

kotlinOptions {
	jvmTarget = rootProject.ext.java.toString()
	freeCompilerArgs = ["-opt-in=kotlin.RequiresOptIn"]
}

}

protobuf {
protoc { artifact = rootProject.ext.libs.protobuf.protoc }
plugins {
java { artifact = rootProject.ext.libs.grpc.protocJava }
grpc { artifact = rootProject.ext.libs.grpc.protocJava }
grpckt { artifact = rootProject.ext.libs.grpc.protocKotlin }
}
generateProtoTasks {
all().each {
it.plugins {
java { option 'lite' }
grpc { option 'lite' }
grpckt { option 'lite' }
}
it.builtins {
kotlin { option 'lite' }
}
}
}
}

@jamesward
Copy link
Collaborator

I think that you need to use a newer maybe 8.1 alpha version of the Android Gradle Plugin with Kotlin 1.8.10. Can you try that?

@HDNAdministrator
Copy link
Author

HDNAdministrator commented Feb 11, 2023

Thanks for the reply.
After experimenting different combinations of versions I found out that the issue is with
id 'com.google.protobuf' version '0.9.2' apply false
If the version is downgraded to 0.9.1 the errors go away.
It is seems to be a bug after reading the issues reported in com.google.protobuf repo.

@jamesward
Copy link
Collaborator

Oh yes - Here is the bug: google/protobuf-gradle-plugin#656

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants