Java 不兼容类型:无法将原型转换为MessageOrBuilder

Java 不兼容类型:无法将原型转换为MessageOrBuilder,java,android,gradle,protocol-buffers,Java,Android,Gradle,Protocol Buffers,我想将protobuf消息打印到json。我做了以下工作: JsonFormat.Printer jsonPrinter = JsonFormat.printer(); StringBuilder toStore = new StringBuilder(); toStore.append("["); toStore.append(jsonPrinter.print(pointRecord.build())); // point record is a builder of protoMessag

我想将protobuf消息打印到json。我做了以下工作:

JsonFormat.Printer jsonPrinter = JsonFormat.printer();
StringBuilder toStore = new StringBuilder();
toStore.append("[");
toStore.append(jsonPrinter.print(pointRecord.build())); // point record is a builder of protoMessage. 
我得到以下错误:

:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
 /app/src/main/java/com/example/exampleapp/RecordsCollector.java:131: error: incompatible types: PointRecord cannot be converted to MessageOrBuilder
        toStore.append(jsonPrinter.print(pointRecord.build()));
                                                          ^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
:app:compileDebugJavaWithJavac FAILED
我想我需要构建完整的protobuf,而不仅仅是lite protobuf。然而,我不知道怎么做。 我将应用程序的gradle.build文件的一部分放在这里:

apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'
...
protobuf { 
    protoc {
        artifact = 'com.google.protobuf:protoc:3.0.0'
    }
    plugins {
       javalite {
           artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
       }
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                remove java
            }
            task.plugins {
                javalite { }
            }
        }
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
     })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.google.protobuf:protobuf-java:3.0.0' 
    compile 'com.google.protobuf:protobuf-java-util:3.0.0' 
    testCompile 'junit:junit:4.12'
}

使用以下代码段编译完整的protobuf版本:

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.0.0'
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java {}
            }
        }
     }
}
…


dependencies {
    implementation 'com.google.protobuf:protobuf-java:3.5.0'
    implementation 'com.google.protobuf:protobuf-java-util:3.5.0'
}