5

Android app crashes in phone when build using Release Type but works fine when build using debug build type or if debugging is enabled in release mode.

Logcat error are showing verify error due to one of the abstract class

There are no proguard files in the application. i have tried by adding 'useProguard false' in build.gradle but it won't help

apply plugin: 'com.android.application'

android {
    useLibrary 'org.apache.http.legacy'
    compileSdkVersion 28

    defaultConfig {
        applicationId "com.newgen.mcap.srei"
        minSdkVersion 21
        targetSdkVersion 28
    }

    buildTypes {
        release {
            minifyEnabled false

        }
    }
    lintOptions {
        checkReleaseBuilds false
        disable "ResourceType"
    }

}

dependencies {
    compile 'com.android.support:support-v4:23.4.0'
    compile files('libs/com.antlersoft.android.db_0.1.6.jar')
    compile files('libs/commons-lang3-3.1.jar')
    compile files('libs/dmsapi.jar')
    compile files('libs/ImgAndro.jar')
    compile files('libs/NGSecurity.jar')
}

Logcat error in here:

    --------- beginning of crash
2019-01-14 16:34:28.599 16678-16696/com.newgen.mcap.srei E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
    Process: com.newgen.mcap.srei, PID: 16678
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:325)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)
     Caused by: java.lang.VerifyError: Rejecting class com.newgen.mcap.client.custom.CustomHelper_1_1 that attempts to sub-type erroneous class com.newgen.mcap.client.util.DefaultCustomHelper (declaration of 'com.newgen.mcap.client.custom.CustomHelper_1_1' appears in /data/app/com.newgen.mcap.srei-1/base.apk)
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:400)
        at java.lang.Class.forName(Class.java:326)
        at com.newgen.mcap.client.util.NGCaptureSingleton.getDefaultCustomHelperForName(NGCaptureSingleton.java:109)
        at com.newgen.mcap.client.util.NGCaptureSingleton.loadXMLConfiguration(NGCaptureSingleton.java:591)
        at com.newgen.mcap.client.util.NGCaptureSingleton.initConfiguration(NGCaptureSingleton.java:414)
        at com.newgen.mcap.client.util.NGCaptureSingleton.setAssets(NGCaptureSingleton.java:96)
        at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:145)
        at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:120)
        at android.os.AsyncTask$2.call(AsyncTask.java:305)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
        at java.lang.Thread.run(Thread.java:761) 
     Caused by: java.lang.VerifyError: Verifier rejected class com.newgen.mcap.client.util.DefaultCustomHelper: java.lang.String[] com.newgen.mcap.client.util.DefaultCustomHelper.selectMasterData(java.lang.String, java.lang.String, java.util.LinkedHashMap, boolean) failed to verify: java.lang.String[] com.newgen.mcap.client.util.DefaultCustomHelper.selectMasterData(java.lang.String, java.lang.String, java.util.LinkedHashMap, boolean): [0xCA] returning undefined register (declaration of 'com.newgen.mcap.client.util.DefaultCustomHelper' appears in /data/app/com.newgen.mcap.srei-1/base.apk)
        at java.lang.Class.classForName(Native Method) 
        at java.lang.Class.forName(Class.java:400) 
        at java.lang.Class.forName(Class.java:326) 
        at com.newgen.mcap.client.util.NGCaptureSingleton.getDefaultCustomHelperForName(NGCaptureSingleton.java:109) 
        at com.newgen.mcap.client.util.NGCaptureSingleton.loadXMLConfiguration(NGCaptureSingleton.java:591) 
        at com.newgen.mcap.client.util.NGCaptureSingleton.initConfiguration(NGCaptureSingleton.java:414) 
        at com.newgen.mcap.client.util.NGCaptureSingleton.setAssets(NGCaptureSingleton.java:96) 
        at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:145) 
        at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:120) 
        at android.os.AsyncTask$2.call(AsyncTask.java:305) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
        at java.lang.Thread.run(Thread.java:761) 

My question is not a duplicate of Link as crash is due to build type and not due to android api level. And i have tried the accepted answer by deleting the build and release folder before building apk.

Bhanu Sharma
  • 111
  • 2
  • 10
  • Possible duplicate of [java.lang.VerifyError: Verifier rejected class on Lollipop when using release APK](https://stackoverflow.com/questions/28031905/java-lang-verifyerror-verifier-rejected-class-on-lollipop-when-using-release-ap) – Karan Harsh Wardhan Jan 15 '19 at 09:09

2 Answers2

0

It is not related to debug/release build. You should handle exception in

com.newgen.mcap.client.util.NGCaptureSingleton.getDefaultCustomHelperForName
(NGCaptureSingleton.java:109)
AIMIN PAN
  • 1,563
  • 1
  • 9
  • 13
0

Steps 1: Open Android Studio Setting and go to Build, Execution, Deployment -> Gradle Copy Gradle Service Directory Path In my case that is C:/Users/bhanu.sharma/.gradle

Step 2: Open File Explorer and Paste the Gradle service directory Path Add the file gradle.properties in here if it is not present

Step 3: Open Android Studio and change project type to Android, You will see gradle.properties file here

Step 4: Add the line android.enableD8=false in gradle.properties file.

Step 5: Clean and Build the signed apk.

Bhanu Sharma
  • 111
  • 2
  • 10