javaproguardgoogle-cloud-endpointsclassnotfoundexceptionclient-library

ClassNotFoundException on class inside gae endpoint client library


I am developing in Java on Eclipse Luna. The packaging process is managed by Proguard.

The app is working fine running against the local datastore repository and on a physical device.

However, I rolled the app out to the Google Play as beta. The app crashes with ClassNotFoundException. The exception is calling against a class that is generated by the GAE's endpoint client library process.

Here are what I have tried so far, but no luck...

  1. Rearrange the build path to put all client library on the top of the list, uncheck the Dependencies and clean the project.

  2. I also tried using the -keepclass option with the full package and class name in the proguard-project.txt.

  3. I added the following entries to my proguard-project.txt...still no luck

    -keep public class * extends com.google.api.client.json.GenericJson # Needed by google-api-client to keep generic types and @Key annotations accessed via reflection** -keepclassmembers class * { @com.google.api.client.util.Key ; } -keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault

Anyone has any clue what I am missing? Thanks!


Solution

  • This is what I ended up adding to my proguard-project.txt file:

    # Needed by google-api-client to keep generic types and @Key annotations accessed via reflection
    -keep public final class * 
    -keep public class *
    
    -keepclassmembers class * {
      public <fields>;
      static <fields>;
      public <methods>;
      protected <methods>;
    }
    
    -keepclassmembers class * extends com.google.api.client.json.GenericJson{
      public <fields>;
      static <fields>;
      public <methods>;
    }
    
    -keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault