应用程序崩溃与毕加索和minifyEnabled真实

时间:2017-03-05 18:54:28

标签: android proguard release

FolderViewModel

这是我在尝试构建release.apk时遇到的错误。

我尝试通过添加:

来修复它
<HierarchicalDataTemplate DataType="{x:Type viewModel:FolderViewModel}" ItemsSource="{Binding Path=Items}">
    <DockPanel>
        <Label Content="{Binding Name}" VerticalAlignment="Center" FontWeight="SemiBold" />
    </DockPanel>
</HierarchicalDataTemplate>

在我的Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl$Builder Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Request$Builder Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Call Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.ResponseBody Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.ResponseBody Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl$Builder Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Request$Builder Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Request Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Call Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.ResponseBody Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl$Builder Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Request$Builder Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.ResponseBody Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache Warning:there were 52 unresolved references to classes or interfaces. Warning:Exception while processing task java.io.IOException: Please correct the above warnings first. Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. Job failed, see logs for details 文件中。

release.apk现在正确构建,至少显然是这样。

但是当我在手机(或任何手机)上安装应用程序时,它会在启动时崩溃,我想当它开始用Picasso加载图像时。

请帮我解决这个问题。

我已经尝试了一些在互联网上找到的解决方案并向您建议,它们似乎都可以正确构建,但应用程序仍然会崩溃。它可能取决于专业防守规则以外的其他东西吗?

这就是我的gradle的样子:

-dontwarn com.squareup.picasso.**

5 个答案:

答案 0 :(得分:41)

你似乎还在缩小OkHTTP

can't find referenced class com.squareup.okhttp

转到Picasso's Github page

-dontwarn com.squareup.okhttp.**

答案 1 :(得分:12)

试试这些你的proguard.cfg:

#### -- Picasso --
 -dontwarn com.squareup.picasso.**

 #### -- OkHttp --

 -dontwarn com.squareup.okhttp.internal.**

 #### -- Apache Commons --

 -dontwarn org.apache.commons.logging.** 

答案 2 :(得分:0)

在您的应用gradle中尝试

minifyEnabled false 收缩资源为假

答案 3 :(得分:0)

我的问题是我无法使用minifyEnabled true生成签名的apk,并且通过将以下内容添加到proguard-rules.pro文件中来修复了该问题:

#for Picasso library
-dontwarn okio.
# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*
# OkHttp platform used only on JVM and when Conscrypt dependency is available.
-dontwarn okhttp3.internal.platform.ConscryptPlatform

或者如果以上仍然引起问题,则可以使用以下内容:

#for Picasso library
-dontwarn com.squareup.okhttp3.**
-keep class com.squareup.okhttp3.* { *;}
-dontwarn okio.
-dontwarn okhttp3.internal.platform.ConscryptPlatform
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault

答案 4 :(得分:0)

解决了在proguard-rules.pro中添加这一行的问题:

-dontwarn com.squareup.okhttp.**