objectbox-java: java.lang.VerifyError: Verifier rejected class ProductCursor: long failed to verify: long. [0x50A] register v256 has type Undefined but expected Integer

Please help us to fix issues asap:

Issue Basics

  • ObjectBox version : 1.5.0
  • Reproducibility: always

Reproducing the bug

Description

This issue started occurring only after upgrading to Android Studio v3.1.3 from v3.1.2.

Code

Occurs whenever i try to access the Box for my Product prodBox.all.size == 0

Logs & stackstraces

Stacktrace:

    Process: com.gfxbandits.invizio, PID: 4412
    java.lang.VerifyError: Verifier rejected class com.gfxbandits.invizio.model.ProductCursor: long com.gfxbandits.invizio.model.ProductCursor.put(com.gfxbandits.invizio.model.Product) failed to verify: long com.gfxbandits.invizio.model.ProductCursor.put(com.gfxbandits.invizio.model.Product): [0x50A] register v256 has type Undefined but expected Integer (declaration of 'com.gfxbandits.invizio.model.ProductCursor' appears in /data/app/com.gfxbandits.invizio-1/split_lib_slice_0_apk.apk)
        at com.gfxbandits.invizio.model.ProductCursor$Factory.createCursor(ProductCursor.java:21)
        at io.objectbox.Transaction.createCursor(Transaction.java:166)
        at io.objectbox.Box.getReader(Box.java:81)
        at io.objectbox.Box.getAll(Box.java:320)
        at com.gfxbandits.invizio.fragment.CatalogueFragment$loadCatalogueOnline$1$1.onComplete(CatalogueFragment.kt:203)
        at com.google.android.gms.tasks.zzj.run(Unknown Source)
        at android.os.Handler.handleCallback(Handler.java:836)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:203)
        at android.app.ActivityThread.main(ActivityThread.java:6251)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

Entities

Product.kt:

import android.os.Parcelable
import io.objectbox.annotation.Entity
import io.objectbox.annotation.Id
import io.objectbox.annotation.Index
import kotlinx.android.parcel.Parcelize

@Parcelize
@Entity
data class Product(@Id var id: Long = 0,
                   var isSynced: Boolean = false,
                   @Index var RFID: String = "",
                   @Index var SKU: String = "",
                   @Index var designNo: String = "",
                   @Index var imageName: String = "",
                   @Index var status: String = STATUS_IN_STOCK,
                   var salesManName: String = "",
                   @Index var type: String = "",
                   @Index var size: String = "",
                   @Index var grossWeight: String = "",
                   @Index var netWeight: String = "",
                   @Index var collectionLine: String = "",
                   @Index var category: String = "",
                   @Index var metalType: String = "",
                   @Index var metalPurity: String = "",
                   var metalWeight: String = "",
                   var totalDiamondWeight: String = "",
                   var totalStoneWeight: String = "",
                   var centerStoneType: String = "",
                   var centerStoneShape: String = "",
                   var centerStoneSize: String = "",
                   var centerStoneQuality: String = "",
                   var centerStoneColor: String = "",
                   var centerStoneWeight: String = "",
                   var centerStoneCertificate: String = "",
                   var centerStoneCut: String = "",
                   var stoneType: String = "",
                   var stoneShape: String = "",
                   var stoneSize: String = "",
                   var stoneQuality: String = "",
                   var stoneColor: String = "",
                   var stoneCount: String = "",
                   var stoneWeight: String = "",
                   var stoneCertificate: String = "",
                   var stoneCut: String = "",
                   var totalStoneCount: String = "",
                   var findingType: String = "",
                   var findingMetal: String = "",
                   var findingWeight: String = "",
                   var findingMetalPurity: String = "",
                   var goldLock: String = "",
                   var silverLock: String = "",
                   var platinumLock: String = "",
                   var costPrice: String = "",
                   var fobPrice: String = "",
                   var sellingPrice: String = "",
                   var metalPrice: String = "",
                   var diamondPrice: String = "",
                   var stonePrice: String = "",
                   var laborPrice: String = "",
                   var laborChargePerGram: String = "",
                   var setID: String = "",
                   var setImageName: String = "",
                   var company: String = "",
                   var location: String = "",
                   var counterNumber: String = "",
                   var counterDescription: String = "",
                   var trayNumber: String = "",
                   var trayDescription: String = "",
                   var owner: String = "",
                   var customer: String = "",
                   var reserved1: String = "",
                   var reserved2: String = "",
                   var reserved3: String = "",
                   var reserved4: String = "",
                   var reserved5: String = "",
                   var reserved6: String = "",
                   var reserved7: String = "",
                   var reserved8: String = "",
                   var reserved9: String = "",
                   var reserved10: String = "",
                   @Index var isSelected: Boolean = true,
                   @Index var isNewlyImported: Boolean = false
) : Parcelable {
  companion object {
    val STATUS_IN_STOCK = "INSTOCK"
    val STATUS_SALES_OUT = "SALESOUT"
    val STATUS_SOLD = "SOLD"
  }
}

Misc

I also tried from Android Studio 3.2 Canary 17 but it still doesn’t work. The app works normally if i downgrade to the last APK Built from Android Studio 3.1.2 (code is still same). I even tried disabling R8 by adding the following line to gradle.properties android.enableR8 = false

I am using the following dependencies/libraries: -Apache POI for Android 3.12

ext {
        kotlin_version = '1.2.41'
        support_lib_version = '27.1.1'
        google_services_version = '15.0.0'
        firebase_version = '15.0.0'
        objectboxVersion = '1.5.0'
        as_version='3.2.0-alpha17'
    }
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "com.android.support:appcompat-v7:$support_lib_version"
implementation "com.android.support:recyclerview-v7:$support_lib_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation "com.android.support:support-v4:$support_lib_version"
implementation "com.android.support:design:$support_lib_version"
implementation "com.android.support:support-vector-drawable:$support_lib_version"
implementation 'com.android.support:support-v4:27.1.1'
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.github.florent37:runtime-permission-kotlin:1.0.1'
implementation 'br.com.simplepass:loading-button-android:1.14.0'
implementation 'com.amitshekhar.android:android-networking:1.0.1'
implementation "com.google.firebase:firebase-core:$firebase_version"
implementation "com.google.firebase:firebase-firestore:$firebase_version"
implementation "com.google.firebase:firebase-storage:$firebase_version"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'
implementation "io.objectbox:objectbox-android:$objectboxVersion"
implementation "io.objectbox:objectbox-kotlin:$objectboxVersion"
kapt "io.objectbox:objectbox-processor:$objectboxVersion"
implementation 'com.jakewharton:butterknife:8.8.1'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.github.ghost1372:Mzip-Android:0.4.0'
implementation 'com.shuhart.stepview:stepview:1.2.7'
implementation 'com.appyvet:materialrangebar:1.4.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'
kapt 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'com.firebaseui:firebase-ui-storage:3.3.1'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation 'com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:0.7.2'
implementation 'com.github.ohoussein.playpauseview:playpauseview:1.0.2'
implementation 'com.github.Ilhasoft:data-binding-validator:1.0.0'
kapt "androidx.databinding:databinding-compiler:$as_version"
implementation 'com.cloudrail:cloudrail-si-android:2.22.1'
implementation 'com.google.code.gson:gson:2.8.4'
implementation 'com.lowagie:itext:4.2.1'
implementation 'com.github.medyo:fancybuttons:1.8.4'

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 28 (9 by maintainers)

Most upvoted comments

Thanks for the report! The issue was routed to the D8 team today. We have a fix and will be pushing it to the 3.2 release branch as soon as possible. We hope to get the fix out for 3.2.0-beta04.

Thanks! Mads

Instead of turning off D8, here is how to use the latest stable D8 build with the fix in Android Studio 3.1 and 3.2 until this fix makes it out in the official studio builds.

In the top-level build.gradle add a D8 maven repo and put the latest stable D8 on the classpath before the gradle plugin.

For Android Studio 3.1:

buildscript {

    repositories {
        maven {
            url "http://storage.googleapis.com/r8-releases/raw"
        }
    }

    dependencies {
        classpath 'com.android.tools:r8:v1.0.34'  // Must be before the Gradle Plugin for Android.
        classpath 'com.android.tools.build:gradle:x.y.z'
     }
}

For Android Studio 3.2:

buildscript {

    repositories {
        maven {
            url "http://storage.googleapis.com/r8-releases/raw"
        }
    }

    dependencies {
        classpath 'com.android.tools:r8:1.2.30'  // Must be before the Gradle Plugin for Android.
        classpath 'com.android.tools.build:gradle:x.y.z'
     }
}

Seems like this is either an error in Google’s byte code verifier or on our side. We’ll investigate, but it might take some days. So, meanwhile, please stick to com.android.tools.build:gradle:3.1.2 until there’s an update.

Android Studio 3.2 is released, which makes the above workaround unnecessary.

TL;DR If you are affected by this, update to Android Studio 3.2.

Closing this then. -ut

This error continues to exist with Android Gradle Plugin 3.2.0-beta02.

However, I narrowed the problem down to the new compiler, D8.

By adding the flag android.enableD8=false to the projects gradle.properties file, as suggested in the Android plugin release notes, the error disappears. -ut

Issue is resolved.

Issue not for Android Studio 3.1.3.

change build.gradle version

com.android.tools.build:gradle:3.1.3 to com.android.tools.build:gradle:3.1.2

Artur, could you try using the latest Android Studio 3.4 release candidate to see if this reproduces with a more recent version of D8. If it still reproduces, could you file a bug report at: https://issuetracker.google.com/issues/new?component=317603

Please include as many details as you can. Does this happen on all devices? If not, which devices does it happen on. If possible, a reproduction example would be great. Alternatively, if you can share your apk so that we can look at the code that would be great as well.

Thanks, Mads

Android Studio 3.2 beta 4 is out, which should make the above workaround unnecessary. -ut

Fix confirmed (using Android Studio 3.2 and R8 1.2.30), the error no longer exists using the example project I submitted. @madsager Thanks for the fast fix and interim solution!

I guess keeping this open until a fix is in an official Studio build. -ut

Submitted issue to Android Studio team: https://issuetracker.google.com/110373181 -ut

@shripal17 OK, can reproduce with the given entity. Will try to determine cause now.

Update:

  • As stated, the error disappears when reverting to com.android.tools.build:gradle:3.1.2.
  • Updating the Kotlin plugin has no effect.
  • Java classes are also affected.
  • The error disappears if at least 2 String properties are removed. Adding removing properties with other types seems to have no effect. For Java classes the limit appears to be 60 String properties, for a Kotlin data class 68 String properties.
  • Can not be related to our bytecode modifications as this only happens if there are relations, which in this case there are none.

For now the only viable workaround is to stick with com.android.tools.build:gradle:3.1.2 and not update to 3.1.3. Not seeing how we are causing a problem there. May need to submit an issue to the Android build tools team.

-ut

I also tried the following procedures: Clean Project -> Make Project Rebuild Project -> Make Project

Closing the Project in Android Studio, Deleting build folders and objectbox-models folders

Re-opening in Android Studio