I get such error during the build:
e: /Users/some/path/SomeClass.java:86: error: cannot find symbol
e:
e: static ConnectionType getConnectionType(Context context) {
e: ^
e: symbol: class ConnectionType
e: location: class SomeClass
Where ConnectionType
is class generated by protobuf. So it looks like kapt doesn't resolve generated classes.
What I've tried?
At first I added kotlin-apt
plugin:
apply plugin: 'kotlin-kapt'
Then I added brotobuf-generated classes to source set:
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
main.java.srcDirs += 'build/generated/source/proto/main/java'
}
And also I want to have generated classes before kapt starts it's work. So I order gradle tasks this way:
afterEvaluate {
def protoTasks = []
tasks.each { task ->
if (task.name.contains('proto') || task.name.contains('Proto')) {
protoTasks.push(task)
}
}
tasks.each { task ->
if (task.name.startsWith('kapt')) {
task.dependsOn protoTasks
}
}
}
But all these things don't help, I still got the same error. How to solve it?
The error was caused by wrong path to protobuf source set. I had to use correct flavor name in it, like:
sourceSets {
// ...
main.java.srcDirs += 'build/generated/source/proto/flavor/java'
}
instead of
sourceSets {
// ...
main.java.srcDirs += 'build/generated/source/proto/main/java'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With