'FATAL EXCEPTION, happening in signed APK (Application closes after opening, works in debug mode)

The app is works very well in debug mode. But in signed apk and after uploading in playstore, the app is closed automatically. I have tried:

  • Rebuild
  • Clean
  • Invalidate and restart
  • Added proguard of adgem

Here is the error in signed APK,

    E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.mas.pns, PID: 3461
    java.lang.NullPointerException: throw with null exception
        at com.adgem.android.internal.g$a.onResponse(SourceFile:2)
        at com.adgem.android.internal.g$c.onResponse(SourceFile)
        at gb.k$b$a$a.run(SourceFile:3)
        at android.os.Handler.handleCallback(Handler.java:754)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:163)
        at android.app.ActivityThread.main(ActivityThread.java:6393)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
2022-05-12 12:39:09.936 3562-3739/? E/##XLogger##: com.miui.cloudservice.cloudcontrol.@IPV6@SourceFile:2, thread:5040--cloud config is not expired , request canceled
2022-05-12 12:39:10.871 1600-1875/? E/FE_LOG: ObservableUtils: accept: 
    java.lang.NullPointerException: The mapper function returned a null value.
        at h.a.d.b.b.a(ObjectHelper.java:1)
        at h.a.d.e.a.c$a.onNext(ObservableMap.java:4)
        at h.a.d.e.a.e.run(ObservableScalarXMap.java:2)
        at h.a.d.e.a.b.b(ObservableJust.java:3)
        at h.a.d.a(Observable.java:20)
        at h.a.d.e.a.c.b(ObservableMap.java:1)
        at h.a.d.a(Observable.java:20)
        at h.a.d.e.a.f$b.run(ObservableSubscribeOn.java:1)
        at h.a.d.g.j.call(ScheduledDirectTask.java:3)
        at h.a.d.g.j.call(ScheduledDirectTask.java:1)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)

Is it anything with my gradle files I don't know exact details so Here is my build. gradle:

android {
    compileSdkVersion 31
    buildToolsVersion "30.0.3"


    buildFeatures {
        viewBinding true
    }


    defaultConfig {
        applicationId "com.mas.pns"
        minSdkVersion 21
        //noinspection OldTargetApi
        targetSdkVersion 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }



    configurations {

        all {

            exclude group : 'commons-logging', module: 'commons-logging'
            exclude group : 'org.apache.httpcomponents', module : 'httpclient'

        }

    }






    buildTypes {
        release {
            minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }





    compileOptions {

        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11

    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.6.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'


    implementation 'androidx.multidex:multidex:2.0.1'




    //firebase
    implementation platform('com.google.firebase:firebase-bom:28.0.1')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.firebase:firebase-firestore'
    implementation 'com.google.firebase:firebase-storage:20.0.1'
    implementation 'com.google.firebase:firebase-database'
    implementation 'com.google.firebase:firebase-messaging:23.0.3'
    implementation 'com.google.android.gms:play-services-auth:20.2.0'



    // Sweet alert box
    implementation 'com.github.f0ris.sweetalert:library:1.6.2'

    // circle imageview
    implementation 'de.hdodenhof:circleimageview:3.1.0'

    implementation 'com.github.bumptech.glide:glide:4.12.0'

    // Smooth bottomBar
    implementation 'com.github.ibrahimsn98:SmoothBottomBar:1.7.6'

    // adGem
    implementation 'com.adgem:adgem-android:3.0.1'

    implementation 'com.karumi:dexter:6.2.2'

    // swipe decorate
    implementation 'com.github.xabaras:RecyclerViewSwipeDecorator:1.3'

    // unity
    implementation files('libs/unity-ads.aar')

    //poll_fish
    implementation 'com.pollfish:pollfish-googleplay:6.1.4'

    // AyEt Studio
    implementation files('libs/ayetpublisher3.6.jar')

    //admob
    implementation 'com.google.android.gms:play-services-ads:20.6.0'
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source