google api java client not passing parameter with value 0 when using proguard-android-optimize.txt












1















I have a Google API java client model class as:



public final class AccountProviders extends com.google.api.client.json.GenericJson


with a parameter lastSyncTime as :



  /**
* @return value or {@code null} for none
*/
public java.lang.Long getLastSyncTime() {
return lastSyncTime;
}


while using proguard configuration :



release {
resValue "string", "app_name", "MyApp"
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'}


things are working fine for 0 or any other long value as the value of lastSyncTime however if using following proguard configuration:



release {
resValue "string", "app_name", "MyApp"
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'}


the API throws 503, as param lastSyncTime is missing from the request, for value 0; it is working fine for other long values



TLDR; using optimized proguard config is stripping the param of google API java client request; if the value of param is 0



please suggest any remedy for this.










share|improve this question





























    1















    I have a Google API java client model class as:



    public final class AccountProviders extends com.google.api.client.json.GenericJson


    with a parameter lastSyncTime as :



      /**
    * @return value or {@code null} for none
    */
    public java.lang.Long getLastSyncTime() {
    return lastSyncTime;
    }


    while using proguard configuration :



    release {
    resValue "string", "app_name", "MyApp"
    minifyEnabled true
    shrinkResources false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'}


    things are working fine for 0 or any other long value as the value of lastSyncTime however if using following proguard configuration:



    release {
    resValue "string", "app_name", "MyApp"
    minifyEnabled true
    shrinkResources false
    proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'}


    the API throws 503, as param lastSyncTime is missing from the request, for value 0; it is working fine for other long values



    TLDR; using optimized proguard config is stripping the param of google API java client request; if the value of param is 0



    please suggest any remedy for this.










    share|improve this question



























      1












      1








      1


      1






      I have a Google API java client model class as:



      public final class AccountProviders extends com.google.api.client.json.GenericJson


      with a parameter lastSyncTime as :



        /**
      * @return value or {@code null} for none
      */
      public java.lang.Long getLastSyncTime() {
      return lastSyncTime;
      }


      while using proguard configuration :



      release {
      resValue "string", "app_name", "MyApp"
      minifyEnabled true
      shrinkResources false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'}


      things are working fine for 0 or any other long value as the value of lastSyncTime however if using following proguard configuration:



      release {
      resValue "string", "app_name", "MyApp"
      minifyEnabled true
      shrinkResources false
      proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'}


      the API throws 503, as param lastSyncTime is missing from the request, for value 0; it is working fine for other long values



      TLDR; using optimized proguard config is stripping the param of google API java client request; if the value of param is 0



      please suggest any remedy for this.










      share|improve this question
















      I have a Google API java client model class as:



      public final class AccountProviders extends com.google.api.client.json.GenericJson


      with a parameter lastSyncTime as :



        /**
      * @return value or {@code null} for none
      */
      public java.lang.Long getLastSyncTime() {
      return lastSyncTime;
      }


      while using proguard configuration :



      release {
      resValue "string", "app_name", "MyApp"
      minifyEnabled true
      shrinkResources false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'}


      things are working fine for 0 or any other long value as the value of lastSyncTime however if using following proguard configuration:



      release {
      resValue "string", "app_name", "MyApp"
      minifyEnabled true
      shrinkResources false
      proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'}


      the API throws 503, as param lastSyncTime is missing from the request, for value 0; it is working fine for other long values



      TLDR; using optimized proguard config is stripping the param of google API java client request; if the value of param is 0



      please suggest any remedy for this.







      android proguard android-proguard google-api-java-client






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 31 '18 at 8:08







      Rahul Tiwari

















      asked Dec 28 '18 at 14:27









      Rahul TiwariRahul Tiwari

      4,22612251




      4,22612251
























          1 Answer
          1






          active

          oldest

          votes


















          1














          What we found was that proguard replaces all instances of new Long(0) with same reference. (same for String/Int etc) So in this case if you have any parameter with 0 value. It would get converted to same reference of new Long(0). Due to this check at isNull in com.google.api.client.util.Data.java resulting in that field being set to null. And hence it would not be passed in your API calls.



          Solution :
          add following line to proguard rules to disable this proguard simplification.



          -optimizations !code/simplification/*





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53960046%2fgoogle-api-java-client-not-passing-parameter-with-value-0-when-using-proguard-an%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            What we found was that proguard replaces all instances of new Long(0) with same reference. (same for String/Int etc) So in this case if you have any parameter with 0 value. It would get converted to same reference of new Long(0). Due to this check at isNull in com.google.api.client.util.Data.java resulting in that field being set to null. And hence it would not be passed in your API calls.



            Solution :
            add following line to proguard rules to disable this proguard simplification.



            -optimizations !code/simplification/*





            share|improve this answer




























              1














              What we found was that proguard replaces all instances of new Long(0) with same reference. (same for String/Int etc) So in this case if you have any parameter with 0 value. It would get converted to same reference of new Long(0). Due to this check at isNull in com.google.api.client.util.Data.java resulting in that field being set to null. And hence it would not be passed in your API calls.



              Solution :
              add following line to proguard rules to disable this proguard simplification.



              -optimizations !code/simplification/*





              share|improve this answer


























                1












                1








                1







                What we found was that proguard replaces all instances of new Long(0) with same reference. (same for String/Int etc) So in this case if you have any parameter with 0 value. It would get converted to same reference of new Long(0). Due to this check at isNull in com.google.api.client.util.Data.java resulting in that field being set to null. And hence it would not be passed in your API calls.



                Solution :
                add following line to proguard rules to disable this proguard simplification.



                -optimizations !code/simplification/*





                share|improve this answer













                What we found was that proguard replaces all instances of new Long(0) with same reference. (same for String/Int etc) So in this case if you have any parameter with 0 value. It would get converted to same reference of new Long(0). Due to this check at isNull in com.google.api.client.util.Data.java resulting in that field being set to null. And hence it would not be passed in your API calls.



                Solution :
                add following line to proguard rules to disable this proguard simplification.



                -optimizations !code/simplification/*






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 31 '18 at 10:47









                AalapAalap

                1,5001720




                1,5001720






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53960046%2fgoogle-api-java-client-not-passing-parameter-with-value-0-when-using-proguard-an%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas