2

I have a problem running my android app on Lollipop 5.0 devices.

When i build a release apk it works fine on all the devices I tested (Android 6,7 and 4). It used to work on my 5.0 device as well a few weeks ago and I can't remember to have changed anything significant. It is a LG G3.

The error I get is:

E/AndroidRuntime: FATAL EXCEPTION: main
                                             Process: com.duke.privatpc.quiztest, PID: 2758
                                             java.lang.VerifyError: Rejecting class com.duke.privatpc.quiztest.Splash because it failed compile-time verification (declaration of 'com.duke.privatpc.quiztest.Splash' appears in /data/app/com.duke.privatpc.quiztest-2/base.apk)
                                                 at java.lang.reflect.Constructor.newInstance(Native Method)
                                                 at java.lang.Class.newInstance(Class.java:1572)
                                                 at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2206)
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
                                                 at android.app.ActivityThread.access$800(ActivityThread.java:148)
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                 at android.os.Looper.loop(Looper.java:135)
                                                 at android.app.ActivityThread.main(ActivityThread.java:5272)
                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                 at java.lang.reflect.Method.invoke(Method.java:372)
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
04-02 12:09:20.038 1014-2108/? I/art: Explicit concurrent mark sweep GC freed 26780(1315KB) AllocSpace objects, 1(16KB) LOS objects, 30% free, 73MB/105MB, paused 1.223ms total 163.987ms

I found some threads about a similar problem, but none of the tips helped. I tried turning of instant run or cleaning the project, but nothing seems to work. The app closes right after launching it.

My Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.duke.privatpc.quiztest"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 5
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':BaseGameUtils')
    compile 'com.anjlab.android.iab.v3:library:1.0.+'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.firebase:firebase-ads:10.2.0'
    testCompile 'junit:junit:4.12'
}


apply plugin: 'com.google.gms.google-services'

The Activity itself is about 22.000 lines as i instantiate a lot of objects. Mainly it is one method, creating 2000 Questions for a Quiz. I know this is neither beautiful code nor the best way to do it as I could have used a database, but I'm at a point where I don't really want to rewrite a big part of the app. Mainly I want to know if this can be caused by having a method that is too big and if there is any way to optimize it?

  • If you really have to do the heavy initialization, I hope you are doing it in an async task and not the main UI thread behind splash screen. You should start the task when the screen appears and once the task finishes you can move to next screen on success callback? Does it make sense? – Hassan Apr 02 '17 at 10:20
  • If this solves your issue let me know and I can write a detailed answer, if not please update your question with your activity's code. – Hassan Apr 02 '17 at 10:21
  • yes it makes sense, i will try this! But how does this problem associate with Lollipop device as it seems to work on any other android version? Edit: I tried to simply comment out the long method, but the app still crashes? – Dustin Keßler Apr 02 '17 at 10:27
  • Actually there can be a number of reasons. Basically its failing to verify your class consistency and security. This might be a result of some android service getting updated, for instance, resulting in tighter rules and the phone now performing differently. Looking at log before and after this exception might also help. The above is a simple rule of thumb that I mentioned, though you might end up rewriting some of your code to make it simpler so it gets verified quickly/easily. – Hassan Apr 02 '17 at 10:35
  • The general exception itself is at https://docs.oracle.com/javase/7/docs/api/java/lang/VerifyError.html States that: Thrown when the "verifier" detects that a class file, though well formed, contains some sort of internal inconsistency or security problem. – Hassan Apr 02 '17 at 10:37
  • Other SO threads you might already have visited: http://stackoverflow.com/questions/30455162/rejecting-class-because-it-failed-compile-time-verification-android http://stackoverflow.com/questions/33551848/rejecting-class-because-it-failed-compile-time-verification – Hassan Apr 02 '17 at 10:40
  • yes i tried all of the tips presented in those threads but nothing seemed to be working – Dustin Keßler Apr 02 '17 at 12:07
  • Were you able to resolve this? What was the issue you finally found out? – Hassan Apr 04 '17 at 15:02
  • well i did, but not by using an asynchronous task. I simply split the methods into a few smaller methods and it worked :) Thank you anayways for your help! – Dustin Keßler Apr 06 '17 at 08:01

0 Answers0