1

I recently uploaded my first Kotlin-Android app to a closed testing (alpha) track in Google Play Console. The review was complete and I shared my link to some testers. Unfortunately the release bundle has major bugs that are not present in the debug APK! (the one that generates automatically when I hit "Run" in Android Studio). I checked both bundles on my device and the debug version works perfectly fine while the release is unusable. Is there anyway to debug a release version??? Or maybe create a debuggable build that mimics it's behaviour (as a release build is set to be undebugable for safety reasons...). Is there a way to see the app logs? (or are they removed in the release build?)

I think it's important to mention that all bugs are related to Firebase actions. My Firebase project have all the needed "SHA certificate fingerprints" (SAH-1 & SHA-256 for the debug, upload & app-signing keys). Maybe another thing is missing?

Maybe the specific bugs can point to the root of the difference, so these are my 2 biggest bugs:

  1. Each user document holds a list of items which is shown in a recyclerView in one of his screens. In the release version no item is shown. I checked the Firestore console and the items are added successfully (from any version) and they show when I sign in the same user with the debug version.
  2. Can't sign in via phone number (in Firebase auth pre-built UI). The other methods work fine. I can even link a phone to an existing account, but the pre-built sign-in flow stops after I enter a phone number and resets to the initial screen. In the debug version that works fine.

Did someone encounter anything like that?

Any help would be appreciated.

Omer Levy
  • 347
  • 4
  • 11

2 Answers2

2

you can add this debuggable true in your gradle file

release {
        debuggable true
        minifyEnabled false
        shrinkResources false
    }

this will help you debug the release version, make sure that minifyEnabled and shrinkResources are false

to run the Release version of the app with the Release Keystore use this

signingConfigs {
    release {
        storeFile file('file location')
        storePassword 'your store password'
        keyAlias 'your key alias'
        keyPassword 'your key password'
    }
}

and then add in the variant of release this

release{
    signingConfig singingConfigs.release
}
Mahmoud Omara
  • 533
  • 6
  • 22
  • I added what you suggested but still when I try to run with the "release" build variant I get this error: "Installation did not succeed.The application could not be installed: INSTALL_PARSE_FAILED_NO_CERTIFICATES". I suppose the internal building process signs the app with the debug key regardless of the variant?... Is there a way to attach the Android Studio debugger to an Android process that wasn't initiated by it? Because the only way I manage to run the buggy bundle is by clicking the icon in my phone – Omer Levy Dec 11 '20 at 14:32
  • you need to uninstall the old one first and then try again – Mahmoud Omara Dec 13 '20 at 10:00
  • I did, it's not that. – Omer Levy Dec 13 '20 at 10:38
  • if my solution worked for u, can u mark it as solved? – Mahmoud Omara Dec 14 '20 at 16:27
  • Thank you for your answer. I actually solved it yesterday evening and am just about to write what worked for me in case other people encounter any of it. The solution is similar to your edited answer but is kind of the opposite - I needed to use the release key instead of the default debug key. – Omer Levy Dec 14 '20 at 21:02
  • 1
    well that is what i meant, to put ur own release key credentials instead of the debug ones i have, thought it was clear from the "storeFile file('file location')", glad it worked out for you – Mahmoud Omara Dec 15 '20 at 10:57
2

I found the way to debug the release bundle. The problem was that the "release" build variant used the default signing key - the debug key. I had to Configure the build process to automatically sign my app with a secured key. At the end, I have the following code in my "build.gradle (:app)" file:

...
def keystorePropertiesFile = rootProject.file(<keystore.properties file location>)
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    signingConfigs {
        ionce {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
...
    buildTypes {
        release {
...
            signingConfig signingConfigs.ionce
        }
    }
...
}
...

(I choose to Remove signing information from my build files. If you do, pay attention to the "\" orientation in the storeFile field as the error is not very informative. This answer helped me)

If anyone also encounter one of the two issues I mentioned, here are the solutions:

  1. The difference between the build variants was that in my "release" variant I use minifyEnabled true, which changes the attributes' names to minify the code. When getting the document from Firestore it did not match the object structure and failed to load the list. The solution is in this answer.
  2. This one was not related to the difference in build types - seems I didn't check the feature after upgrading firebase-auth library in my gradle. Upgrading the firebase-ui-auth library, like in this answer, did the trick :)
Omer Levy
  • 347
  • 4
  • 11