Android Youtube API V3 cast exception when Release+Proguard ON -
i have android app utilises youtube.search.list method. application works fine when in "debug" , when proguard disabled in "release".
when proguard turned on (minifyenabled true), following exception when iterate list of searchresult class
com.google.api.client.util.arraymap cannot cast com.google.api.services.youtube.model.searchresult
i set following rules in proguard-rules (according advice in comments in question "android proguard makes youtube api oauth disabled?")
-keep class com.google.api.** { *; }
the following code segment retrieves list < searchresult > . part works fine (searchresultlist.size() returns 25).
youtube = new youtube.builder(new nethttptransport(), new jacksonfactory(), request->{}) .setapplicationname("youtube-search") .build(); search = youtube.search() .list("id,snippet") .setkey(developerkey.developer_key) .setq("test") .setmaxresults(25); searchlistresponse searchresponse = search.execute(); list<searchresult> searchresultlist = searchresponse.getitems()
the following loop cause error occur
for (searchresult r: searchresultlist){ // program throws exception in "release" proguard on. }
any insights appreciated.
i have same problem while building proguard, add line in proguard rule :
-keepattributes signature
and works me.
from proguard official site :
for example, should @ least keep exceptions, innerclasses, , signature attributes when processing library.
Comments
Post a Comment