title: java.lang.VerifyError: Verifier rejected class - failed to verify
body: <p>I am using <code>protobuf</code> to auto-generate my API services, in <a href="https://grpc.io/docs/tutorials/basic/android.html" rel="nofollow noreferrer"><code>gRPC</code></a> technology, in my android client. It's been months since i have been working on it without a problem. Now all of a sudden, the AndroidRuntime Verifier is rejecting one of the auto-generated methods of my API.</p>
  
  <hr>
  
  <p><strong>Here is the stacktrace:</strong></p>
  
  <pre><code>com.company.companyplayer E/AndroidRuntime: FATAL EXCEPTION: main
                                          Process: com.company.companyplayer, PID: 18181
                                          java.lang.VerifyError: Verifier rejected class company.v1.PlayerEarningsPageDataResponse: void company.v1.PlayerEarningsPageDataResponse.mergeNextDepositDate(com.google.protobuf.Timestamp) failed to verify: void company.v1.PlayerEarningsPageDataResponse.mergeNextDepositDate(com.google.protobuf.Timestamp): [0x26] register v5 has type Precise Reference: com.google.protobuf.Timestamp but expected Reference: com.google.protobuf.GeneratedMessageLiteVerifier rejected class company.v1.PlayerEarningsPageDataResponse: java.lang.Object company.v1.PlayerEarningsPageDataResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object) failed to verify: java.lang.Object company.v1.PlayerEarningsPageDataResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object): [0x16E] register v8 has type Precise Reference: com.google.protobuf.Timestamp but expected Reference: com.google.protobuf.GeneratedMessageLite (declaration of 'company.v1.PlayerEarningsPageDataResponse' appears in /data/app/com.company.companyplayer-1/split_lib_slice_4_apk.apk)
                                              at company.v1.PlayerEarningsPageDataResponse.getDefaultInstance(PlayerEarningsPageDataResponse.java:0)
                                              at company.v1.APIGrpc.&lt;clinit&gt;(APIGrpc.java:47)
                                              at company.v1.APIGrpc.newStub(APIGrpc.java:0)
                                              at com.company.companyplayer.backend.Client.getAuthAsyncStub(Client.java:103)
                                              at com.company.companyplayer.backend.Client.playerLogin(Client.java:119)
                                              at com.company.companyplayer.ui.activity.LoginActivity.loginAndGoToMainActivity(LoginActivity.java:202)
                                              at com.company.companyplayer.ui.activity.LoginActivity.onActivityResult(LoginActivity.java:127)
                                              at android.app.Activity.dispatchActivityResult(Activity.java:6935)
                                              at android.app.ActivityThread.deliverResults(ActivityThread.java:4086)
                                              at android.app.ActivityThread.handleSendResult(ActivityThread.java:4133)
                                              at android.app.ActivityThread.-wrap20(ActivityThread.java)
                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1534)
                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                              at android.os.Looper.loop(Looper.java:154)
                                              at android.app.ActivityThread.main(ActivityThread.java:6121)
                                              at java.lang.reflect.Method.invoke(Native Method)
                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
  </code></pre>
  
  <hr>
  
  <p><strong>The following (solutions suggested on similar SO posts) did not work:</strong></p>
  
  <ul>
  <li>Clean and re-build (even tried cleaning manually)</li>
  <li>Invalidate Caches &amp; Restart IDE</li>
  <li>Regenerate API definition from proto</li>
  </ul>
  
  <hr>
  
  <p><strong>Also, here is the auto-generated method pointed out in the stacktrace:</strong></p>
  
  <pre><code>  private void mergeNextDepositDate(com.google.protobuf.Timestamp value) {
      if (nextDepositDate_ != null &amp;&amp; nextDepositDate_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
        nextDepositDate_ = com.google.protobuf.Timestamp.newBuilder(nextDepositDate_).mergeFrom(value).buildPartial();
      } else {
        nextDepositDate_ = value;
      } 
    }
  </code></pre>
  
  <p>It can be seen that the method is neither very lengthy, nor takes too many parameters; somethings that have been said be common causes for this error.</p>
  
  <hr>
  
  <p><strong>Following is the build.gradle for my app:</strong> (Nothing has been changed in the gradle since the last time that all of this was working fine)</p>
  
  <pre><code>apply plugin: 'com.android.application'
  apply plugin: 'com.google.protobuf'
  
  android {
      compileSdkVersion 25
      buildToolsVersion '25.0.3'
      defaultConfig {
          applicationId "com.company.companyplayer"
          minSdkVersion 15
          targetSdkVersion 25
          versionCode 5
          versionName "0.1"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
          multiDexEnabled true
          vectorDrawables.useSupportLibrary = true
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
              signingConfig signingConfigs.config
          }
      }
      lintOptions {
          disable 'InvalidPackage'
      }
  }
  
  protobuf {
      protoc {
          artifact = 'com.google.protobuf:protoc:3.2.0'
      }
      plugins {
          javalite {
              artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
          }
          grpc {
              artifact = 'io.grpc:protoc-gen-grpc-java:1.3.0'
          }
      }
      generateProtoTasks {
          all().each { task -&gt;
              task.plugins {
                  javalite {}
                  grpc {
                      // Options added to --grpc_out
                      option 'lite'
                  }
              }
          }
      }
  }
  
  dependencies {
      compile fileTree(include: ['*.jar'], dir: 'libs')
      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
          exclude group: 'com.android.support', module: 'support-annotations'
      })
      /* android support libraries */
      compile 'com.google.android:flexbox:0.2.7'
      compile 'com.android.support:multidex:1.0.1'
      compile 'com.google.firebase:firebase-config:11.0.1'
      compile 'com.google.firebase:firebase-core:11.0.1'
      compile 'com.google.firebase:firebase-messaging:11.0.1'
      compile 'com.google.android.gms:play-services-maps:11.0.1'
      compile 'com.google.android.gms:play-services-location:11.0.1'
      compile 'com.google.maps.android:android-maps-utils:0.4.4'
      compile 'com.google.code.findbugs:jsr305:3.0.1'
      compile 'io.grpc:grpc-okhttp:1.3.0'
      compile 'io.grpc:grpc-protobuf-lite:1.3.0'
      compile 'io.grpc:grpc-stub:1.3.0'
      compile 'com.facebook.android:facebook-android-sdk:[4,5)'
      compile 'com.facebook.android:account-kit-sdk:4.22.0'
      compile 'javax.annotation:javax.annotation-api:1.2'
      compile 'com.google.api.grpc:googleapis-common-protos:0.0.3' // This is for importing "google/api/annotations.proto" in our proto file
      testCompile 'junit:junit:4.12'
      androidTestCompile 'com.google.code.findbugs:jsr305:3.0.1'
      protobuf 'com.google.protobuf:protobuf-java:3.1.0'
  }
  
  apply plugin: 'com.google.gms.google-services'
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE:</strong> The error has definitely something to do with <code>google.protobuf.Timestamp</code>. Here is the <a href="https://github.com/abdulwasae/google.protobuf.timestamp-java.lang.VerifyError" rel="nofollow noreferrer"><strong>link to an MWE</strong></a> that reproduces this problem.</p>