2016-08-08 59 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行。 –