Ich möchte einen Grpc-Client auf Android schreiben. Ich folge this tutorialProtobuf auf Android: Error Duplicate Klassen in Protokolldatei definiert, wenn kompilieren
Hier ist meine äußere build.gradle
Datei:
apply plugin: 'java'
apply plugin: 'com.google.protobuf'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.0"
}
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.2.0"
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.3.0'
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
}
allprojects {
repositories {
jcenter()
mavenLocal()
}
}
Hier ist meine innere Datei build.gradle
Datei:
dependencies {
compile 'com.android.support:appcompat-v7:23.+'
// You need to build grpc-java to obtain these libraries below.
compile 'io.grpc:grpc-okhttp:1.3.0' // CURRENT_GRPC_VERSION
compile 'io.grpc:grpc-protobuf-lite:1.3.0' // CURRENT_GRPC_VERSION
compile 'io.grpc:grpc-stub:1.3.0' // CURRENT_GRPC_VERSION
compile 'javax.annotation:javax.annotation-api:1.2'
}
Als ich versuchte Projekt zu bauen, habe ich immer Fehler erfüllen:
Error:(14, 15) error: duplicate class: io.grpc.routeguideexample.Feature
Error:(13, 15) error: duplicate class: io.grpc.routeguideexample.FeatureDatabase
// ...
Mit Feature
... ist eine Klasse, die ich in der Protokolldatei definiert habe. Bitte helfen Sie mir herauszufinden, was in meinem Code falsch ist.
Dank