Android youtube/gdata api 在运行 proguard 后无法工作

发布于 2024-10-19 21:53:44 字数 434 浏览 1 评论 0原文

有没有人在使用 youtube api 时遇到问题,特别是在运行 proguard 之后? 我从 youtube 获取视频的代码在运行 proguard 之前工作得很好,在运行 proguard 之后我得到了奇怪的异常,

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

我没有在任何地方设置内容类型,并且我使用的是创建新项目时生成的默认 proguard.cfg 文件。< br> 运行 proguard 后有人遇到类似的问题吗? 尝试了没有混淆、没有优化的 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ζ澈沫 2024-10-26 21:53:44

不确定 google-api-client 是否与您提到的 gdata 完全相同,但它一定非常相似。由于 Proguard 经常会破坏您的代码,因此您必须告诉它它可以做什么和不能做什么。它绝不是理解反射的神奇工具。

我必须在其他内容中添加以下内容:

-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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文