12

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?

Community
  • 1
  • 1
misaochan
  • 890
  • 2
  • 8
  • 25
  • Why are you going with static class for serialization and deserialization? – Anurag Singh Feb 22 '17 at 07:40
  • @misaochan editing the same question and adding a bounty to that question is more than enough to bounce back to the top of active questions rather than posting a new question and link the old one since the issue is same.Next time consider that ! – Charuක Feb 22 '17 at 07:43
  • are you applying proguard to release build but not to debug build? – CoderP Mar 01 '17 at 05:03

3 Answers3

9

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

marmor
  • 27,641
  • 11
  • 107
  • 150
1

Try building the debug build with proguard and see if the issue replicates. In your build.gradle do this:

buildTypes {
        all{
            // Place all proguard files
            proguardFile 'proguard/proguard-rules.pro'
            proguardFile getDefaultProguardFile('proguard-android.txt')
           }
}
CoderP
  • 1,361
  • 1
  • 13
  • 19
0

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.