如何解决从 1.25.0 更新到 1.34.1 后 GRPC 找不到 simbol 错误
如果我使用旧版本,Protobuf 会成功生成我的 protos,但是当我将我的 protobuf 依赖项更新到最新的 1.34.1 时,我总是遇到这个问题。
如果我使用旧版本,Protobuf 会成功生成我的 protos,但是当我将我的 protobuf 依赖项更新到最新的 1.34.1 时,我总是遇到这个问题。
C:\Users\1\AndroidStudioProjects\capella-client-androidd\app\build\generated\source\proto\debug\javalite\api\AbonentOuterClass.java:337: error: an enum switch case label must be the unqualified name of an enumeration constant
case IS_INITIALIZED: {
^
C:\Users\1\AndroidStudioProjects\capella-client-androidd\app\build\generated\source\proto\debug\javalite\api\AbonentOuterClass.java:340: error: an enum switch case label must be the unqualified name of an enumeration constant
case MAKE_IMMUTABLE: {
^
C:\Users\1\AndroidStudioProjects\capella-client-androidd\app\build\generated\source\proto\debug\javalite\api\AbonentOuterClass.java:346: error: an enum switch case label must be the unqualified name of an enumeration constant
case VISIT: {
^
C:\Users\1\AndroidStudioProjects\capella-client-androidd\app\build\generated\source\proto\debug\javalite\api\AbonentOuterClass.java:347: error: cannot find symbol
Visitor visitor = (Visitor) arg0;
^
symbol: class Visitor
location: class LoginRequest
C:\Users\1\AndroidStudioProjects\capella-client-androidd\app\build\generated\source\proto\debug\javalite\api\AbonentOuterClass.java:347: error: cannot find symbol
Visitor visitor = (Visitor) arg0;
^
symbol: class Visitor
location: class LoginRequest
C:\Users\1\AndroidStudioProjects\capella-client-androidd\app\build\generated\source\proto\debug\javalite\api\AbonentOuterClass.java:353: error: cannot find symbol
if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor
^
symbol: variable MergeFromVisitor
location: class GeneratedMessageLite
我的 gradle 模块
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.protobuf'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}
protobuf {
protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
plugins {
javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.34.1' // CURRENT_GRPC_VERSION
}
}
generateProtoTasks {
all().each { task ->
task.builtins{
remove java
}
task.plugins {
javalite { }
grpc { // Options added to --grpc_out
option 'lite' }
}
}
}
}
android {
compileSdkVersion 30
buildToolsversion "30.0.3"
defaultConfig {
applicationId "com.glonass.glonassmobile"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
}
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinoptions {
jvmTarget = '1.8'
}
}
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
def nav_version = "2.3.2"
def fragment_version = "1.3.0-rc01"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//For using fragment result listener
implementation "androidx.fragment:fragment-ktx:$fragment_version"
implementation "androidx.fragment:fragment-ktx:$fragment_version"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation 'io.grpc:grpc-okhttp:1.34.1' // CURRENT_GRPC_VERSION
implementation 'io.grpc:grpc-protobuf-lite:1.34.1' // CURRENT_GRPC_VERSION
implementation 'io.grpc:grpc-stub:1.34.1' // CURRENT_GRPC_VERSION
implementation 'io.grpc:grpc-testing:1.34.1' // CURRENT_GRPC_VERSION
implementation 'javax.annotation:javax.annotation-api:1.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
}
我的构建 gradle 项目
buildscript {
ext.kotlin_version = "1.3.72"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.14'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。