![](/img/trans.png)
[英]Cling UPnP library for Android. Not seeing devices after shutdown and restart
[英]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 !
以下是我的計划進入:
-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手冊之后好了,並且通過修改上面的prguard文件的最后一行,我終於做了很多命中和試驗
-keepattributes Annotation ,InnerClasses,Signature
一切正常
來自proguard
指定類,字段或方法的通用簽名。 編譯器可能需要此信息來正確編譯使用編譯庫中的泛型類型的類。 代碼可以通過反射訪問此簽名。
問題是反思
proguard正在破壞,即觸及Cling lib中的類/接口,你需要防止...
你可以從這里開始假設你有一個問題,Proguard觸摸了一些與Jetty / Http堆棧相關的網絡,我猜你的錯誤內容。 狂野的猜測是它好像http實體或主體不能被處理為實現正確的接口...你想配置proguard以避免該庫中的所有接口,並且你的proguard中沒有任何“保持接口”指令。 。
例如,你是否告訴proguard不要觸及'org.eclipse.jetty'中的任何接口。 你沒有這樣做,你可能想要。
看到這里
掃描用於-keepinterface的proguard手冊,以與在lib中實現server / http連接的jetty包一起使用。
了解更多關於庫中內部客戶端 - 服務器和內部網絡堆棧實現的'cling'包/接口(看起來它像某些協議(例如http)上的CS連接實現了jetty)
在lib的jar / archive上構建一個包列表,與你的proguard配置進行比較。 特別注意jetty的服務器實現使用的接口“jar -tf my.jar | sort | uniq”或者其他一些
看看'mapping.txt'中的proguard以及'seeds.txt'中解釋的是什么 。 將這些包名稱從那些相應的列表與上面匯編的包和列表相交,你不希望proguard弄亂。 '種子'應該包含您的碼頭類/接口。 '映射'不應該!
也許您可以嘗試添加-keepclassmembers
以及包org.fourthline.cling
-keep class
,如下所示:
-keep class org.fourthline.cling.** { *;}
-keepclassmembers class org.fourthline.cling.** { *;}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.