После исключения 'protolite-well-known-types' встретите ошибку Verifier отклонил класс com.google.firestore.v1.WriteResponse - PullRequest
1 голос
/ 21 марта 2019

Я создаю приложение для Android с Firebase Firestore и облачным голосовым API.Я обнаружил, что существует конфликт «protobuf» между firestore и com.google.protobuf.Итак, я исключаю «protolite-well-known-types» в app / build.gradle.Вот мое приложение / build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.protobuf'

android {
    compileSdkVersion 28

    defaultConfig {
        applicationId "com.gigamole.sample"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/proguard/androidx-annotations.pro'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/INDEX.LIST'
    }
    configurations.all {
        exclude group: 'com.google.protobuf', module: 'protobuf-lite'
    }
}

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.3.0'
    }
    plugins {
        javalite {
            artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
        }
        grpc {
            artifact = "io.grpc:protoc-gen-grpc-java:1.19.0"
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.plugins {
                javalite {}
                grpc {
                    // Options added to --grpc_out
                    option 'lite'
                }
            }
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':LoadingDialog')
    implementation project(':infinitecycleviewpager')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.github.stankoutils:app:1.3.10'
    implementation 'com.github.devlight.navigationtabstrip:navigationtabstrip:1.0.4'
    implementation 'com.github.bumptech.glide:glide:3.8.0'
    implementation 'org.jetbrains:annotations-java5:15.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.github.florent37:diagonallayout:1.1.1'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.flaviofaria:kenburnsview:1.0.7'
    implementation 'com.github.rubensousa:raiflatbutton:0.1'
    implementation 'com.github.medyo:fancybuttons:1.9.1'
    implementation 'com.jaeger.statusbaruitl:library:1.3.6'
    implementation 'com.ramotion.foldingcell:folding-cell:1.2.2'
    implementation 'com.readystatesoftware.systembartint:systembartint:1.0.3'
    implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-alpha-21'
    implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-21'
    implementation 'jp.wasabeef:glide-transformations:2.0.1'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.okhttp:mockwebserver:2.4.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
    implementation 'devlight.io:navigationtabbar:1.2.5'

    implementation 'com.google.cloud:google-cloud-speech:0.82.0-beta'

    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation('com.google.firebase:firebase-firestore:18.1.0') {
        exclude group: 'com.google.firebase', module: 'protolite-well-known-types'
    }
    implementation 'com.google.firebase:firebase-storage:16.0.5'
    implementation 'com.google.firebase:firebase-ml-vision:19.0.0'
    implementation 'com.google.firebase:firebase-database:16.1.0'
    implementation 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'
    // google cloud speech-to-text api suite

    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.2'
    protobuf 'com.google.protobuf:protobuf-java:3.4.0'
    implementation 'io.grpc:grpc-protobuf-lite:1.19.0'
    implementation 'io.grpc:grpc-stub:1.19.0'
    implementation 'javax.annotation:javax.annotation-api:1.2'
    implementation 'io.grpc:grpc-okhttp:1.19.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.jaeger.statusbaruitl:library:1.3.6'
    implementation 'jp.wasabeef:glide-transformations:2.0.1'
    implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'

    implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-21'
    implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-alpha-21'
    implementation 'com.readystatesoftware.systembartint:systembartint:1.0.3'
    implementation 'com.github.florent37:materialtextfield:1.0.7'

    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.2'
    implementation 'devlight.io:navigationtabbar:1.2.5'

}
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '28.0.0'
            }
        }
    }
}

Затем, когда я использую firestore, возникает ошибка:

myRef = FirebaseFirestore.getInstance().document("userInfo/" + email);
        myRef.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
            @Override
            public void onSuccess(DocumentSnapshot documentSnapshot) {
                Log.d(TAG, "queried userInfo succeed");
                String username = documentSnapshot.getString("username");
                Log.d(TAG, "username is " + username);
            }
        });

Ошибка выглядит так:

2019-03-20 21:34:18.677 7326-7326/com.gigamole.sample E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.gigamole.sample, PID: 7326
    java.lang.RuntimeException: Internal error in Firestore (18.1.0).
        at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$5(com.google.firebase:firebase-firestore@@18.1.0:379)
        at com.google.firebase.firestore.util.AsyncQueue$$Lambda$5.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.VerifyError: Verifier rejected class com.google.firestore.v1.WriteResponse: void com.google.firestore.v1.WriteResponse.mergeCommitTime(com.google.protobuf.Timestamp) failed to verify: void com.google.firestore.v1.WriteResponse.mergeCommitTime(com.google.protobuf.Timestamp): [0x10] register v3 has type Precise Reference: com.google.protobuf.Timestamp but expected Reference: com.google.protobuf.GeneratedMessageLiteVerifier rejected class com.google.firestore.v1.WriteResponse: java.lang.Object com.google.firestore.v1.WriteResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object) failed to verify: java.lang.Object com.google.firestore.v1.WriteResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object): [0x7B] register v5 has type Precise Reference: com.google.protobuf.Timestamp but expected Reference: com.google.protobuf.GeneratedMessageLite (declaration of 'com.google.firestore.v1.WriteResponse' appears in /data/app/com.gigamole.sample-Ek91q5ZY3HAYBGRQKrqEng==/split_lib_dependencies_apk.apk!classes2.dex)
        at com.google.firestore.v1.WriteResponse.getDefaultInstance(com.google.firebase:firebase-firestore@@18.1.0:1012)
        at com.google.firestore.v1.FirestoreGrpc.getWriteMethod(com.google.firebase:firebase-firestore@@18.1.0:379)
        at com.google.firebase.firestore.remote.WriteStream.<init>(com.google.firebase:firebase-firestore@@18.1.0:75)
        at com.google.firebase.firestore.remote.Datastore.createWriteStream(com.google.firebase:firebase-firestore@@18.1.0:154)
        at com.google.firebase.firestore.remote.RemoteStore.<init>(com.google.firebase:firebase-firestore@@18.1.0:186)
        at com.google.firebase.firestore.core.FirestoreClient.initialize(com.google.firebase:firebase-firestore@@18.1.0:247)
        at com.google.firebase.firestore.core.FirestoreClient.lambda$new$2(com.google.firebase:firebase-firestore@@18.1.0:116)
        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@@18.1.0: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@@18.1.0:287)
        at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(Unknown Source:4)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
        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:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@18.1.0:205)
        at java.lang.Thread.run(Thread.java:764)

Кто-нибудь знает, что это за ошибка?Большое спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...