【发布时间】:2020-09-30 17:20:07
【问题描述】:
这次在使用 GCP 做项目时,使用 Firebase 完成代码后,在添加 Cloud Vision 时出现错误。 因此,异常处理阻止了依赖冲突,但发生了另一个错误。错误内容如下。
[项目 Build.gradle]
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
[app Build.gradle]
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion '28.0.3'
packagingOptions{}
defaultConfig {
applicationId "com.example.voca"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/INDEX.LIST'
exclude 'build-data.properties'
}
configurations {
implementation.exclude module:'protolite-well-known-types'
//implementation.exclude module:'proto-google-comon-protos'
//implementation.exclude group:'com.google.guava'
//implementation.exclude module:'protobuf-java'
implementation.exclude module:'protobuf-javalite'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:appcompat-v7:29.0.0'
implementation 'com.google.cloud:google-cloud-vision:1.99.3'
implementation 'com.android.support:design:29.0.0'
implementation('com.google.api-client:google-api-client-android:1.30.9')
implementation('com.google.http-client:google-http-client-gson:1.35.0')
//{OR}
//파이어 베이스
implementation('com.google.firebase:firebase-core:17.4.0')
implementation('com.google.firebase:firebase-database:18.0.0')
implementation('com.google.firebase:firebase-firestore:20.0.0')
implementation('com.google.capillary:lib-android:1.0.0', {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
})
}
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.voca, PID: 24074
java.lang.RuntimeException: Internal error in Firestore (19.0.2).
at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$5(com.google.firebase:firebase-firestore@@19.0.2:379)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$5.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NoSuchFieldError: No static field IS_RESTRICTED_APPENGINE of type Z in class Lio/grpc/internal/GrpcUtil; or its superclasses (declaration of 'io.grpc.internal.GrpcUtil' appears in /data/app/com.example.voca-PC8_IVzX02rxZmfGRpj9gQ==/base.apk!classes4.dex)
at io.grpc.okhttp.OkHttpChannelBuilder.createSslSocketFactory(OkHttpChannelBuilder.java:451)
at io.grpc.okhttp.OkHttpChannelBuilder.buildTransportFactory(OkHttpChannelBuilder.java:418)
at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:513)
at io.grpc.android.AndroidChannelBuilder.build(AndroidChannelBuilder.java:176)
at com.google.firebase.firestore.remote.Datastore.<init>(com.google.firebase:firebase-firestore@@19.0.2:131)
at com.google.firebase.firestore.core.FirestoreClient.initialize(com.google.firebase:firebase-firestore@@19.0.2:261)
at com.google.firebase.firestore.core.FirestoreClient.lambda$new$2(com.google.firebase:firebase-firestore@@19.0.2:117)
at com.google.firebase.firestore.core.FirestoreClient$$Lambda$2.run(Unknown Source:8)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$4(com.google.firebase:firebase-firestore@@19.0.2:311)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$4.call(Unknown Source:2)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$3(com.google.firebase:firebase-firestore@@19.0.2:287)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(Unknown Source:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@19.0.2:205)
at java.lang.Thread.run(Thread.java:764)
我该如何处理这个错误?请回答。 :(
【问题讨论】:
-
您如何使用
com.android.support:appcompat-v7:29.0.0?那version doesn't exist. -
我不知道。 Android Studio 向我显示了一个警告,我将其修复为与构建目标相同。如果有其他方法,请告诉我
标签: android firebase google-cloud-platform grpc dependency-management