• 5
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Android 9 crash minifyEnabled and multiDexEnabled

I'm trying to shrink my apk size by setting minifyEnabled and shrinkResources to true, but on start my application crashes with this error (short version):

java.lang.ClassNotFoundException: Didn't find class "...BaseApplication" on path: DexPathList...

I found many solutions for this error, but it seems, that everybody has crashes only on android 4.x.x. I'm testing on android 9 and still have this problem. Gradle looks like this:

defaultConfig {
    minSdkVersion 17
    targetSdkVersion 28
    versionName "1.0"

    multiDexEnabled  true
}

And buildTypes:

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

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

And also I've added this one in my application class:

override fun attachBaseContext(base: Context?) {
    MultiDex.install(this)
    super.attachBaseContext(base)
}

I only have this error, if I'm trying to start the release build. When I start the debug variant with same settings, all works fine. And also if I'm adding "debuggable true" to my release variant it's ok. It's only occurs, when I'm trying to start my release variant like described above. Has anyone an Idea?

when you do minifyEnabled true in release it means you need to mention what all files you dont want to obfuscate for eg. BaseApplication by mentioning it in proguard-rules.pro

Kindly write below line in proguard-rules.pro it will remove the above error with BaseApplication Class

-keep public class * extends android.app.Application

Kindly refer this link for further understanding about proguard.

If you are facing more problem kindly share content from proguard file.

  • 1
Reply Report
      • 2
    • Very nice, thank you! But why there is a different behavior between starting as debug or release? It's both the same config :)