Android Cling/Upnp proguard

Android Cling/Upnp proguard

我已经使用 Cling 创建了应用程序并且工作正常但是当我创建发布版本时我收到以下消息并且渲染器没有播放任何内容:

   11-22 16:24:53.341  20172-20172/? I/RendererCommand﹕ TrackMetadata : TrackMetadata [id=1, title=IMG-20151120-WA0007, artist=, genre=, artURI=res=http://192.168.1.4:8089/1.jpg, itemClass=object.item.imageItem]
11-22 16:24:53.345  20172-20172/? V/RendererCommand﹕ Resume
11-22 16:24:53.351  20172-20301/? W/RendererCommand﹕ Fail to stop ! Error: Current state of service prevents invoking that action. Error writing request message. Can't transform message payload: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType. (HTTP response was: 500 Internal Server Error)
11-22 16:24:53.351  20172-20301/? I/RendererCommand﹕ Set uri to http://192.168.1.4:8089/1.jpg
11-22 16:24:53.353  20172-20386/? D/RendererCommand﹕ Update state !
11-22 16:24:53.354  20172-20264/? W/RendererCommand﹕ Fail to set URI ! Error: Current state of service prevents invoking that action. Error writing request message. Can't transform message payload: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType. (HTTP response was: 500 Internal Server Error)
11-22 16:24:53.354  20172-20262/? W/RendererCommand﹕ Fail to get position info ! Error: Current state of service prevents invoking that action. Error writing request message. Can't transform message payload: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType. (HTTP response was: 500 Internal Server Error)
11-22 16:24:54.354  20172-20386/? D/RendererCommand﹕ Update state !

下面是我的proguard条目:

-dontoptimize
-dontshrink
-dontskipnonpubliclibraryclasses
-dontpreverify
-allowaccessmodification
-verbose

-dontwarn org.fourthline.cling.**
-dontwarn org.seamless.**
-dontwarn org.eclipse.jetty.**
-dontwarn android.support.v4.app.**
-dontwarn android.support.design.widget.**

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keep class javax.** { *; }
-keep class org.** { *; }
-keep class org.fourthline.cling.** { *;}
-keep class org.seamless.** { *;}
-keep class org.eclipse.jetty.** { *;}
-keep class org.slf4j.** { *;}
-keep class javax.servlet.** { *;}

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}


-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }

-keepattributes *Annotation*

proguard 正在损坏,即在 Cling 库中接触 classes/interfaces,您需要防止这种情况...

你可以开始 here 假设你有 Proguard 接触 Jetty/Http 堆栈中相关的一些网络的问题我猜从你的错误内容。疯狂的猜测是,它好像无法将 http 实体或正文作为实现适当的接口来处理......你想配置混淆器以避免该库中的所有接口,并且你的混淆器中没有任何 "keep interface" 指令。 ..

例如,您是否告诉混淆器不要接触 'org.eclipse.jetty' 中的任何接口。你没有这样做,你可能想这样做。

here

扫描 -keepinterface 的 proguard 手册,以与在您的库中实现 server/http 连接的码头包一起使用。

  1. 了解更多有关 'cling' packages/interfaces 围绕内部客户端-服务器和内部网络堆栈实现的更多信息(看起来它在某些协议上为 C-S 连接实现了码头像 http )

  2. 在库的 jar/archive 上构建一个包列表,以与您的混淆器配置进行比较。特别注意 jetty 的服务器实现 "jar -tf my.jar | sort | uniq" 或某些此类

  3. 使用的接口
  4. 看看 'mapping.txt' 和 'seeds.txt' explain here 中混淆器混淆了什么。将那些各自列表中的那些包名称与上面组装的包和列表相交,你不希望 proguard 搞砸。 'seeds' 应该包含您的码头 classes/interfaces。 'mapping' 不应该!

也许您可以尝试在包 org.fourthline.cling-keep class 之外添加 -keepclassmembers,如下所示:

-keep class org.fourthline.cling.** { *;}
-keepclassmembers class org.fourthline.cling.** { *;}

好的,在阅读了 proguard 手册并进行了多次尝试后,我终于通过将上述 prguard 文件的最后一行修改为

-keepattributes Annotation, InnerClasses, Signature

一切正常

来自混淆器

Specifies the generic signature of the class, field, or method. Compilers may need this information to properly compile classes that use generic types from compiled libraries. Code may access this signature by reflection.

问题正在反思