Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 568
misaochan Avatar asked Oct 25 '16 05:10

misaochan


People also ask

How to debug an APK in Android Studio?

To start debugging an APK, click Profile or debug APK from the Android Studio Welcome screen. Or, if you already have a project open, click File > Profile or Debug APK from the menu bar. In the next dialog window, select the APK you want to import into Android Studio and click OK.

Can Android Studio Open APK files?

Drag an APK or app bundle into the Editor window of Android Studio. Switch to the Project perspective in the Project window and then double-click the APK in the default build/output/apks/ directory.


1 Answers

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

like image 196
marmor Avatar answered Sep 19 '22 18:09

marmor