Skip to content

java.lang.VerifyError: Verifier rejected class  #607

Closed

Description

@h-amg

The error occurs when I attempt to retrieve data from firestore while writing data works totally fine.

Exception message:

Caused by: java.lang.VerifyError: Verifier rejected class com.google.firestore.v1.WriteResponse due to bad method java.lang.Object com.google.firestore.v1.WriteResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object) (declaration of 'com.google.firestore.v1.WriteResponse' appears in /data/app/com.app.android.name-1/split_lib_dependencies_apk.apk:classes2.dex)

  • The code runs normally anywhere but inside firestore onComplete callback method:

           try{
                 userDocRef = db.collection("***s").document("******************sa");
                 userDocRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
                     @Override
                     public void onComplete(@NonNull Task<DocumentSnapshot> task) {
                         if (task.isSuccessful()) {
                             DocumentSnapshot document = task.getResult();
                             if (document.exists()) {
                                 Log.d(TAG, "DocumentSnapshot data: " + document.getData());
                             } else {
                                 Log.d(TAG, "No such document");
                             }
                         } else {
                             Log.d(TAG, "get failed with ", task.getException());
                         }
                     }
                 });
             }catch (Exception e){
                 Log.d(TAG, "Error retrieving user doc data: " + e);
             }
    

DebugLogs:

07-11 08:02:11.603 27666-27666/com.app.android.name W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
07-11 08:02:11.613 27666-27666/com.app.android.name D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, 0) or=1
07-11 08:02:11.653 27666-28056/com.app.android.name I/DynamiteModule: Considering local module providerinstaller:0 and remote module providerinstaller:0
07-11 08:02:11.653 27666-28056/com.app.android.name W/ProviderInstaller: Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
07-11 08:02:11.653 27666-28056/com.app.android.name W/ResourcesManager: getTopLevelResources: /data/app/com.google.android.gms-1/base.apk / 1.0 running in com.app.android.name rsrc of package null
07-11 08:02:11.683 27666-27666/com.app.android.name I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@ff29e8d time:147037202
07-11 08:02:11.723 27666-29453/com.app.android.name I/art: Verification error in void com.google.firestore.v1.WriteResponse.mergeCommitTime(com.google.protobuf.Timestamp)
07-11 08:02:11.723 27666-29453/com.app.android.name I/art: void com.google.firestore.v1.WriteResponse.mergeCommitTime(com.google.protobuf.Timestamp): [0x10] couldn't find method com.google.protobuf.Timestamp$Builder.mergeFrom (Lcom/google/protobuf/GeneratedMessageLite;)Lcom/google/protobuf/GeneratedMessageLite$Builder;
07-11 08:02:11.723 27666-29453/com.app.android.name I/art: 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.GeneratedMessageLite
07-11 08:02:11.723 27666-29453/com.app.android.name I/art: Verification error in java.lang.Object com.google.firestore.v1.WriteResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object)
07-11 08:02:11.723 27666-29453/com.app.android.name I/art: java.lang.Object com.google.firestore.v1.WriteResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object): [0x5C] couldn't find method com.google.protobuf.Timestamp.toBuilder ()Lcom/google/protobuf/GeneratedMessageLite$Builder;
07-11 08:02:11.723 27666-29453/com.app.android.name I/art: java.lang.Object com.google.firestore.v1.WriteResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object): [0x73] couldn't find method com.google.protobuf.Timestamp$Builder.mergeFrom (Lcom/google/protobuf/GeneratedMessageLite;)Lcom/google/protobuf/GeneratedMessageLite$Builder;
07-11 08:02:11.723 27666-29453/com.app.android.name I/art: 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): [0x73] register v5 has type Precise Reference: com.google.protobuf.Timestamp but expected Reference: com.google.protobuf.GeneratedMessageLite
07-11 08:02:11.723 27666-29453/com.app.android.name W/art: Verification failed on class com.google.firestore.v1.WriteResponse in /data/app/com.app.android.name-1/split_lib_dependencies_apk.apk because: Verifier rejected class com.google.firestore.v1.WriteResponse due to bad method java.lang.Object com.google.firestore.v1.WriteResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object)
07-11 08:02:11.733 27666-27666/com.app.android.name D/AndroidRuntime: Shutting down VM
07-11 08:02:11.733 27666-27666/com.app.android.name E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.android.name, PID: 27666
java.lang.RuntimeException: Internal error in Firestore (20.1.0).
at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$5(com.google.firebase:firebase-firestore@@20.1.0:379)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$5.run(com.google.firebase:firebase-firestore@@20.1.0)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.VerifyError: Verifier rejected class com.google.firestore.v1.WriteResponse due to bad method java.lang.Object com.google.firestore.v1.WriteResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object) (declaration of 'com.google.firestore.v1.WriteResponse' appears in /data/app/com.app.android.name-1/split_lib_dependencies_apk.apk)
at com.google.firestore.v1.WriteResponse.getDefaultInstance(com.google.firebase:firebase-firestore@@20.1.0:1012)
at com.google.firestore.v1.FirestoreGrpc.getWriteMethod(com.google.firebase:firebase-firestore@@20.1.0:379)
at com.google.firebase.firestore.remote.WriteStream.(com.google.firebase:firebase-firestore@@20.1.0:74)
at com.google.firebase.firestore.remote.Datastore.createWriteStream(com.google.firebase:firebase-firestore@@20.1.0:104)
at com.google.firebase.firestore.remote.RemoteStore.(com.google.firebase:firebase-firestore@@20.1.0:186)
at com.google.firebase.firestore.core.FirestoreClient.initialize(com.google.firebase:firebase-firestore@@20.1.0:263)
at com.google.firebase.firestore.core.FirestoreClient.lambda$new$2(com.google.firebase:firebase-firestore@@20.1.0:117)
at com.google.firebase.firestore.core.FirestoreClient$$Lambda$2.run(com.google.firebase:firebase-firestore@@20.1.0)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$4(com.google.firebase:firebase-firestore@@20.1.0:311)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$4.call(com.google.firebase:firebase-firestore@@20.1.0)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$3(com.google.firebase:firebase-firestore@@20.1.0:287)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(com.google.firebase:firebase-firestore@@20.1.0)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@20.1.0:205)
at java.lang.Thread.run(Thread.java:818)
07-11 08:02:11.863 27666-27685/com.app.android.name W/art: Suspending all threads took: 62.326ms
07-11 08:02:11.893 27666-27685/com.app.android.name I/art: Background sticky concurrent mark sweep GC freed 78605(5MB) AllocSpace objects, 48(2MB) LOS objects, 18% free, 28MB/35MB, paused 63.394ms total 143.944ms
07-11 08:02:11.963 27666-28056/com.app.android.name V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 284 native methods...
07-11 08:02:12.073 27666-28056/com.app.android.name I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java7ExtendedSSLSession>
07-11 08:02:12.083 27666-28056/com.app.android.name I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java7ExtendedSSLSession>
07-11 08:02:12.083 27666-28056/com.app.android.name I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java8ExtendedSSLSession>
07-11 08:02:12.083 27666-28056/com.app.android.name I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java8ExtendedSSLSession>
07-11 08:02:12.133 27666-28056/com.app.android.name I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL

Build.gradle:

   apply plugin: 'com.android.application'
   
   android {
       compileSdkVersion 28
       buildToolsVersion "29.0.0"
       defaultConfig {
           applicationId 'com.app.android.name'
           minSdkVersion 21
           targetSdkVersion 28
           versionCode 1
           versionName "1.0"
           // enable multidex
           multiDexEnabled true
           testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
           javaCompileOptions {
               annotationProcessorOptions {
                   includeCompileClasspath false
               }
           }
           // backwards compatibility for vector drawables
           vectorDrawables.useSupportLibrary = true
       }
       buildTypes {
           release {
               minifyEnabled false
               proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
           }
       }
   
       compileOptions {
           sourceCompatibility JavaVersion.VERSION_1_8
           targetCompatibility JavaVersion.VERSION_1_8
       }
   
       packagingOptions {
           exclude 'META-INF/DEPENDENCIES'
           exclude 'META-INF/NOTICE'
           exclude 'META-INF/LICENSE'
           exclude 'META-INF/LICENSE.txt'
           exclude 'META-INF/NOTICE.txt'
           exclude 'META-INF/INDEX.LIST'
       }
   
       configurations {
           implementation.exclude module: 'protolite-well-known-types'
           implementation.exclude module: 'protobuf-lite'
       }
   }
   
   dependencies {
       implementation fileTree(dir: 'libs', include: ['*.jar'])
       implementation 'androidx.appcompat:appcompat:1.0.2'
       implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
       testImplementation 'junit:junit:4.13-beta-3'
       androidTestImplementation 'androidx.test:runner:1.2.0'
       androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
       implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
   
       //Multidex to enable over 64k methods limit
       implementation 'androidx.multidex:multidex:2.0.1'
   
       // UI Navigation controller
       implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0-alpha06'
       implementation 'androidx.navigation:navigation-ui-ktx:2.1.0-alpha06'
   
       implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
   
       // butter knife
       implementation 'com.google.android.material:material:1.1.0-alpha07'
       implementation 'com.jakewharton:butterknife:10.1.0'
       annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
   
       //animation (SpinKit)
       implementation 'com.github.ybq:Android-SpinKit:1.2.0'
   
       // VaibhavLakhera Circular Progress View
       implementation "com.github.VaibhavLakhera:Circular-Progress-View:0.1.2"
   
       // circular progressbar cardinalNow
       implementation 'com.github.CardinalNow:Android-CircleProgressIndicator:v0.2'
   
   
       // firebase
       implementation 'com.google.firebase:firebase-core:17.0.0'
       implementation 'com.google.firebase:firebase-auth:18.0.0'
       implementation 'com.google.firebase:firebase-firestore:20.1.0'
   
   
       // Dialogflow Java V2
       implementation 'com.google.cloud:google-cloud-dialogflow:0.98.0-alpha'
   
       // for Remote Procedure Call to avoid "No functional channel service provider found" error while creating SessionsClient
       implementation 'io.grpc:grpc-okhttp:1.21.0'
       implementation 'io.grpc:grpc-auth:1.21.0'
   
   
   
       // transition everywhere
       implementation 'com.andkulikov:transitionseverywhere:2.0.0-beta01'
   
       //MPAndroidChart
       implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
   }
   
   apply plugin: 'com.google.gms.google-services'
   apply plugin: 'com.jakewharton.butterknife'

Note:
I had duplicate classes issue between firebase and dialogflow earlier hence the excluded classes below:

   android {
   
       ...
   
       configurations {
           implementation.exclude module: 'protolite-well-known-types'
           implementation.exclude module: 'protobuf-lite' 
       }
   }

Activity

  1. google-oss-bot commented on Jul 12, 2019

    @google-oss-bot
    Collaborator

    I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

  2. h-amg commented on Jul 12, 2019

    @h-amg
    Author

    @var-const let me know if you need any more information

  3. self-assigned this
    on Jul 12, 2019
  4. var-const commented on Jul 15, 2019

    @var-const
    Contributor

    @h-amg I think what happens is that implementation.exclude excludes Firestore dependencies, which leads to a runtime error once those dependencies are used. I could successfully run a sample app using the gradle config and the code snippet you provided by replacing the excludes with:

               implementation.exclude module: 'proto-google-common-protos'
               implementation.exclude module: 'protobuf-java'

    Can you please try this config? Does it work for you?

  5. h-amg commented on Jul 15, 2019

    @h-amg
    Author

    @h-amg I think what happens is that implementation.exclude excludes Firestore dependencies, which leads to a runtime error once those dependencies are used. I could successfully run a sample app using the gradle config and the code snippet you provided by replacing the excludes with:

               implementation.exclude module: 'proto-google-common-protos'
               implementation.exclude module: 'protobuf-java'
    

    Can you please try this config? Does it work for you?

    @var-const thanks, tried the config above but it didn't work. I get the following error messages:

    error: cannot access GeneratedMessageV3
    class file for com.google.protobuf.GeneratedMessageV3 not found

    error: cannot access MessageOrBuilder
    class file for com.google.protobuf.MessageOrBuilder not found

    You can reproduce it with this main_activity class:

        package com.main.android.applicationtesting;
    
        import androidx.appcompat.app.AppCompatActivity;
    
        import android.os.Bundle;
        import android.util.Log;
        import android.view.KeyEvent;
        import android.view.View;
        import android.widget.Button;
        import android.widget.EditText;
        import android.widget.TextView;
        import android.widget.Toast;
    
        import com.google.cloud.dialogflow.v2.DetectIntentResponse;
        import com.google.cloud.dialogflow.v2.QueryInput;
        import com.google.cloud.dialogflow.v2.SessionName;
        import com.google.cloud.dialogflow.v2.SessionsClient;
        import com.google.cloud.dialogflow.v2.TextInput;
    
    
        public class MainActivity extends AppCompatActivity {
            private static final String TAG = "MainActivity";
    
            private TextView mTextView;
            private Button mBtn;
            private EditText inputText;
            private SessionsClient sessionsClient;
            private SessionName session;;
    
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_main);
    
                mTextView = findViewById(R.id.txt);
                mBtn = findViewById(R.id.btn);
                inputText = findViewById(R.id.input);
                SessionsClient sessionsClient;
                SessionName session;
    
                mBtn.setOnClickListener(this::sendMessage);
    
                //on enter clicked listener to send msg
                inputText.setOnKeyListener((view, keyCode, event) -> {
                    if (event.getAction() == KeyEvent.ACTION_DOWN) {
                        switch (keyCode) {
                            case KeyEvent.KEYCODE_DPAD_CENTER:
                            case KeyEvent.KEYCODE_ENTER:
                                sendMessage(mBtn);
                                return true;
                            default:
                                break;
                        }
                    }
                    return false;
                });
            }
    
            public void callbackV2(DetectIntentResponse response) {
                if (response != null) {
                    String botReply = response.getQueryResult().getFulfillmentText();
                    Log.d(TAG, "V2 Bot Reply: " + botReply);
                    mTextView.setText(botReply);
                } else {
                    Log.d(TAG, "V2Bot Reply: Null");
                    mTextView.setText("There was some communication issue. Please Try again!");
                }
            }
    
            private void sendMessage(View view) {
                String msg = inputText.getText().toString();
                if (msg.trim().isEmpty()) {
                    Toast.makeText(MainActivity.this, "Please write something here",
                            Toast.LENGTH_LONG).show();
                } else {
                    inputText.setText(""); // empty edit textbox
    
                    QueryInput queryInput = QueryInput.newBuilder().setText(TextInput.newBuilder()
                            .setText(msg).setLanguageCode("en-US")).build();
                    new RequestJavaV2Task(MainActivity.this, session, sessionsClient,
                            queryInput).execute();
                }
            }
        }
    

    And add this java class to you to project java folder:

        package com.main.android.applicationtesting;
    
        import android.app.Activity;
        import android.os.AsyncTask;
        import android.util.Log;
    
        import com.google.cloud.dialogflow.v2.DetectIntentRequest;
        import com.google.cloud.dialogflow.v2.DetectIntentResponse;
        import com.google.cloud.dialogflow.v2.QueryInput;
        import com.google.cloud.dialogflow.v2.SessionName;
        import com.google.cloud.dialogflow.v2.SessionsClient;
    
        public class RequestJavaV2Task extends AsyncTask<Void, Void, DetectIntentResponse> {
            private static final String TAG = "RequestJavaV2Task";
    
            private Activity activity;
            private SessionName session;
            private SessionsClient sessionsClient;
            private QueryInput queryInput;
    
             RequestJavaV2Task(Activity activity, SessionName session, SessionsClient sessionsClient, QueryInput queryInput) {
                this.activity = activity;
                this.session = session;
                this.sessionsClient = sessionsClient;
                this.queryInput = queryInput;
            }
    
            @Override
            protected DetectIntentResponse doInBackground(Void... voids) {
                try{
                    DetectIntentRequest detectIntentRequest =
                            DetectIntentRequest.newBuilder()
                                    .setSession(session.toString())
                                    .setQueryInput(queryInput)
                                    .build();
                    return sessionsClient.detectIntent(detectIntentRequest);
                } catch (Exception e) {
                    e.printStackTrace();
                    Log.d(TAG, String.valueOf(e));
                }
                return null;
            }
    
            @Override
            protected void onPostExecute(DetectIntentResponse response) {
                ((MainActivity) activity).callbackV2(response);
            }
        }
    
  6. var-const commented on Jul 15, 2019

    @var-const
    Contributor

    @h-amg Unfortunately, I don't think it's possible to make this setup work. protobuf-java and protobuf-lite are mutually exclusive, and your current config has dependencies that need both of them to be present. Note that dialogflow, which appears to be the dependency that needs protobuf-java, isn't supported on Android:

    Caution:The Java client library does not support Android.
    

    You would have to remove one of the conflicting dependencies, so that either all of your dependencies use protobuf-lite or they all use protobuf-java. I'm sorry I don't have a better solution for you.

  7. removed their assignment
    on Jul 15, 2019
  8. locked and limited conversation to collaborators on Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions