working - usb debugging android 8




Google Play APK and Android Studio APK(USB debug) behaving differently (2)

I posted a question previously: 'No args constructor for class does not exist', but it does and received an answer that worked when I tested it using the USB debug mode on my phone via Android Studio. However, when I pushed the app to Google Play, it ceases to work and causes the same error that I described in that question. I repeated the test today and the same thing happens.

To clarify, I am testing the:

  • Exact same code
  • On the exact same phone
  • Running the exact same Android version
  • Using the exact same image

Is there any reason why the Google Play APK would behave differently from the Android Studio APK? Or am I missing something?


Depending on your build.gradle config, release versions usually run ProGuard on your code. debug versions usually don't run such tools on the code.

So what might have happened is that ProGuard ran over your code, found that MwVolleyApi$Page is not used anywhere, and deleted it.

To test this theory, in your build.gradle turn off minifyEnabled:

release {
    minifyEnabled false
    ...
}

Then build a release-apk, and test it.

BTW, you should always test release apks on your device before uploading them to Google Play, you can install them via adb install or copy them to the sd card and install them from the Downloads app on your phone.

If this indeed fixed the problem, you can add rules to your proguard.cfg file to save the Page class from deletion, something like:

-keep class fr.free.nrw.commons.upload.MwVolleyApi$Page {*;}

Then you can turn minifyEnabled back to true, and test again


I think the apk you are building from your Android Studio is the debug version, which is user for debugging during development. The apk which is published on Google Play Store is the release version of your app.

You can also build a release version from Android Studio and see that it will be exact same version as found on the play Store.







gson