如何解决发布版本类型导致Android应用程序崩溃但调试版本类型起作用的问题

时间:2019-01-15 08:55:17

标签: java android

使用发布类型进行构建时,Android应用程序在手机中崩溃,但是当使用调试构建类型进行构建或在发布模式下启用调试时,Android应用程序可以正常工作。

Logcat错误显示由于抽象类之一而导致的验证错误

应用程序中没有proguard文件。我尝试通过添加 build.gradle中的'useProguard false',但无济于事

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错误:

    --------- 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) 

我的问题不是Link的重复项 因为崩溃是由于构建类型而不是由于android api级别。而且我在构建apk之前先删除了build和release文件夹,从而尝试了可接受的答案。

2 个答案:

答案 0 :(得分:0)

它与调试/发布版本无关。您应该在

中处理异常
com.newgen.mcap.client.util.NGCaptureSingleton.getDefaultCustomHelperForName
(NGCaptureSingleton.java:109)

答案 1 :(得分:0)

步骤1:打开Android Studio设置,然后转到“构建,执行,部署-> Gradle” 复制Gradle服务目录路径 在我的情况下是C:/Users/bhanu.sharma/.gradle

步骤2:打开文件资源管理器并粘贴Gradle服务目录路径 如果文件gradle.properties不存在,请在此处添加

第3步:打开Android Studio并将项目类型更改为Android,您将看到 gradle.properties文件在这里

第4步:在gradle.properties文件中添加android.enableD8 = false行。

第5步:清理并构建已签名的APK。