简体   繁体   中英

VerifyError: Verifier rejected class ... 'this' arg must be initialized

after third-party library upgrade I got a new crash on app launch:

java.lang.VerifyError: Verifier rejected class ly.img.android.e: void ly.img.android.e.<init>(java.lang.String, boolean) failed to verify: void ly.img.android.e.<init>(java.lang.String, boolean): [0x5C] 'this' arg must be initialized (declaration of 'ly.img.android.e' appears in base.apk!classes2.dex)
    at ly.img.android.b.<clinit>(Unknown Source:46)
    at ly.img.android.c.b(Unknown Source:0)
    at ly.img.android.PESDK.initSDK(Unknown Source:0)
    at ly.img.android.IMGLYAutoInit.onCreate(IMGLYAutoInit.java:41)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:2092)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:2066)
    at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)

Yes, I know that there are a lot of similar problems there but I didn't find any solution or advise for me.

So, maybe someone there can provide hint or advise for me what's wrong there. Thanks

Others were also facing this kind of issue, I think this can help you!

java.lang.VerifyError: Verifier rejected class ly.img.android.e: void ly.img.android.e.<init>(java.lang.String, boolean) failed to verify: void ly.img.android.e.<init>(java.lang.String, boolean): [0x5C] 'this' arg must be initialized (declaration of 'ly.img.android.e' appears in base.apk.classes2.dex)

But according to a GitHub thread they found a solution to this problem

https://github.com/CleverTap/clevertap-android-sdk/issues/15#issuecomment-454842450

The fix for this issue is available for AGP(Android Gradle Plugin) 3.3 (and 3.4) by setting an explicit dependency detailed below. After AGP 3.3.1 is released, remove the pinned version to allow you to pick up new D8/R8 releases again.

For AGP 3.3 amend your top-level build.gradle file with:

buildscript {
    repositories {
        maven {
            url "http://storage.googleapis.com/r8-releases/raw" // ADD THIS.
        }
    }
    dependencies {
        classpath 'com.android.tools:r8:1.3.52'  // ADD THIS. Must be before the Gradle Plugin for Android.
        classpath 'com.android.tools.build:gradle:3.3'
    }
}

For AGP 3.4 the r8 version should be 1.4.25

I have a suggestion Maybe it will help

android {

    defaultConfig {
       ...
        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

and

 implementation 'com.android.support:multidex:1.0.0'

How did I resolve the issue:

I have upgraded gradle version from 3.5.3 to 3.6.3 . Ough and thank you. Maybe my experience can help somebody.

I think this is the probelm with third-party library.

In my case, I built the library .jar myself and had no idea why the VerifyError would appear when trying to test the .jar in a test application.

The problem was in proguard.cfg with -assumenosideeffects and Log .

Specifically, inside proguard.cfg (of my library) there was a following line:

-assumenosideeffects class android.util.Log {*;}

Replacing it with:

-assumenosideeffects class android.util.Log {
    public static *** v(...);
    public static *** d(...);
    public static *** i(...);
    public static *** w(...);
    public static *** e(...);
}

and building and obfuscating it again resolved the problem.

I found the answer to my problem here .

I know this doesn't directly answer to the original question, but I left this answer here in order to help someone who is trying to build the .jar and the result of using it is VerifyError .

I had a similar error:

FATAL EXCEPTION: Connection#7864356
    Process: ..., PID: 24458
    java.lang.VerifyError: Verifier rejected class r8.a: r8.b r8.a.b(w8.a[]) failed to verify: r8.b r8.a.b(w8.a[]): [0x33] expected to be within a catch-all for an instruction where a monitor is held (declaration of 'r8.a' appears in /data/app/~~DIy9qxh1lGM...==/base.apk)
        at p7.g$b.b(SourceFile:270)
        at p7.g$b.run(SourceFile:35)

This happened after I updated gradle from 4.2.2 to 7.3.1 . I tried disabling obfuscation and the @Keep option for the specified classes in the error message. But nothing helped. In debug mode, everything still worked, but in the release the app crashed with an error.

Thanks Dupinder Singh. I've changed my top-level build.gradle file with:

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools:r8:4.0.48'
        classpath 'com.android.tools.build:gradle:7.3.1'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Now everything works. Maybe my solution will help someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM