Xterra
Xterra

Reputation: 11

Android youtube/gdata api not working after running proguard

Did anyone have trouble with youtube api especially after running proguard? My code to fetch videos from youtube worked just fine before running proguard, after running proguard i am getting strange exception

 ERROR/AndroidRuntime(10197): Caused by: java.lang.IllegalArgumentException: 
No parser defined for Content-Type: application/atom+xml; charset=UTF-8; type=feed

I'm not setting content type anywhere and i'm using the default proguard.cfg file that's generated while creating a new project.
Did anyone face similar issues after running proguard? Tried proguard without obfuscating, without optimization but it gives the same result.

Upvotes: 1

Views: 1264

Answers (1)

pjv
pjv

Reputation: 10708

Not sure if google-api-client is exactly the same as the gdata you mention, but it must be very similar. Since Proguard will often break your code, you have to tell it what it can and cannot do. It's not by any means a miracle tool that understands reflection.

I had to add this among others:

-keepattributes *Annotation* # Needed by google-api-client
-keepattributes Signature # Needed by google-api-client 

# Needed by google-api-client to keep generic types and @Key annotations accessed via reflection
-keepclassmembers class * {
  @com.google.api.client.util.Key <fields>;
}

# Needed by Guava (google-api-client)
-dontwarn sun.misc.Unsafe

Upvotes: 7

Related Questions