Search code examples
androidandroid-sqliterelease

Why does my app give an error when I run the release APK, but not the debug APK?


I'm going to give you some context first about the functionality of my specific app. It's an Android app programmed in Java, and it's a B2B app for selling to representatives, so the first thing the app has is a login so that just anyone can't access it. The problem arises when I generate the release APK, which causes the login to stop working and kicks me out of the app. I think it might be because it can't communicate with the webservice or the local database, or something like that. The debug APK works correctly. I've tried several things and can't seem to find the solution.I've also heard something about Proguard, but I'm not sure how it works or if it would have anything to do with this.

I've tried changing the signature, deleting the generated Java folder, and other things, but none of them have been useful.


Solution

  • The problem is most likely caused by proguard which by default minifys and obfuscates release builds.

    Try dissabling proguard for the release build and check if the app works as intended. If yes, you have found the problem and can now analyze which classes need to remain de-obfuscated for your release build. See this thread for this.

    In your app module's build.gradle file:

    buildTypes {
        ...
        release {
            minifyEnabled false
        ...
        }
    }