2016-08-08 92 views
0

我在我的新Android項目中使用Azure mobile app。 當我在調試模式下運行應用程序時,移動應用程序成功運行,我可以在我的表格中看到我的新記錄。當使用Azure移動應用程序時,Android prouard崩潰

我的問題是開始時,我用proguard創建一個apk文件。 我很抱歉地說我是Proguard的新手,那麼即使我閱讀官方Proguard頁面上的文檔,我也無法解決我的Proguard問題。

因此,當我嘗試使用Proguard創建沒有任何Proguard代碼的apk文件時,我得到這些錯誤。

Warning: com.google.common.base.Absent: can't find referenced class javax.annotation.Nullable 
Warning: com.google.common.base.Absent: can't find referenced class javax.annotation.Nullable 
Warning: com.google.common.base.Ascii: can't find referenced class javax.annotation.CheckReturnValue 
Warning: com.google.common.base.CaseFormat$StringConverter: can't find referenced class javax.annotation.Nullable 
Warning: com.google.common.base.CharMatcher: can't find referenced class javax.annotation.CheckReturnValue 
Warning: com.google.common.base.CharMatcher: can't find referenced class javax.annotation.CheckReturnValue 
Warning: com.google.common.base.CharMatcher: can't find referenced class javax.annotation.CheckReturnValue 

多hundreads線...

Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe 
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe 
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe 
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe 
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe 
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe 
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe 
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe 

多hundreads線....

Warning: okio.Okio: can't find referenced class java.nio.file.Files 
Warning: okio.Okio: can't find referenced class java.nio.file.Files 
Warning: okio.Okio: can't find referenced class java.nio.file.Files 
Warning: okio.Okio: can't find referenced class java.nio.file.Path 
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption 
Warning: okio.Okio: can't find referenced class java.nio.file.Path 
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption 
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 
Warning: okio.Okio: can't find referenced class java.nio.file.Path 
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption 
Warning: okio.Okio: can't find referenced class java.nio.file.Path 
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption 
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 

然後我在proguard的添加了這些行。

-keep class okio.** { *; } 
-dontwarn okio.** 
-keep class com.fasterxml.** { *; } 
-dontwarn com.fasterxml.** 

-dontwarn javax.annotation.** 
-dontwarn javax.inject.** 
-dontwarn sun.misc.Unsafe 

-keep class com.microsoft.windowsazure.mobileservices.** { *; } 
-dontwarn android.os.** 
-dontwarn com.microsoft.windowsazure.mobileservices.RequestAsyncTask 

之後,Android工作室創建了apk然而,應用程序一旦啓動就會被啓動。然後我調查日誌,發現顏色爲白色的新警告。

Note: duplicate definition of library class [org.apache.http.conn.scheme.LayeredSocketFactory] 
Note: duplicate definition of library class [org.apache.http.conn.scheme.SocketFactory] 
Note: duplicate definition of library class [org.apache.http.conn.scheme.HostNameResolver] 
Note: duplicate definition of library class [org.apache.http.conn.ConnectTimeoutException] 
Note: duplicate definition of library class [org.apache.http.params.CoreConnectionPNames] 
Note: duplicate definition of library class [org.apache.http.params.HttpParams] 
Note: duplicate definition of library class [org.apache.http.params.HttpConnectionParams] 
Note: duplicate definition of library class [android.net.http.SslError] 
Note: duplicate definition of library class [android.net.http.HttpResponseCache] 
Note: duplicate definition of library class [android.net.http.SslCertificate$DName] 
Note: duplicate definition of library class [android.net.http.SslCertificate] 
Note: there were 11 duplicate class definitions. 
     (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass) 

感謝您的幫助。

回答

1

@MustafaOlkun,您的問題的解決方案似乎可以在ProGuard的troubleshooting頁面找到。

對於問題Warning: can't find referenced class,請參閱http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass

對於問題Note: duplicate definition of library class,請參閱http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass

希望它有幫助。

+0

感謝您的提前,添加Fabric crahslatics工具後,我看到了我的應用程序崩潰的位置,並且我明白必須爲我的一些java文件(從Serializeble實現)添加新的-keep和-keepclassmembers行。 –