Search code examples
androidyoutube-apiyoutube-data-apiandroid-youtube-api

android - Youtube api 400 Bad Request


The YouTube Api is giving the following error, though I have provided "snippet" as part in the query and it is working well in debug version and not working in my signed Apk version

{
   "errors" : [ {
   "domain" : "global",
   "reason" : "required",
   "message" : "Required parameter: part",
   "locationType" : "parameter",
   "location" : "part"
   } ],
   "code" : 400,
   "message" : "Required parameter: part"
}

Here is my query code: query = youTube.playlists().list("snippet");

 query.setKey(getYTkey());
 query.setChannelId(con[0].getString(R.string.CHANNEL_ID));
 query.setMaxResults((long) 25);

Solution

  • Change the proguard rules as follows:

    -keep class com.google.**
    -keep interface com.google.** { *;}
    -dontwarn com.google.**
    
    -keep class com.google.api.** {
        *;
    }
    
    # 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 google-http-client-android when linking against an older platform version
    -dontwarn com.google.api.client.extensions.android.**
    
    # Needed by google-api-client-android when linking against an older platform version
    -dontwarn com.google.api.client.googleapis.extensions.android.**
    
    # Needed by google-play-services when linking against an older platform version
    -keep class com.google.android.gms.** { *; }
    -dontwarn com.google.android.gms.**
    -dontnote com.google.android.gms.**
    # com.google.client.util.IOUtils references java.nio.file.Files when on Java 7+
    -dontnote java.nio.file.Files, java.nio.file.Path
    
    # Suppress notes on LicensingServices
    -dontnote **.ILicensingService
    
    # Suppress warnings on sun.misc.Unsafe
    -dontnote sun.misc.Unsafe
    -dontwarn sun.misc.Unsafe