简体   繁体   English

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

[英]App crashing with Picasso and minifyEnabled true

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

This is the error I was getting when trying to build my release.apk. 这是我在尝试构建release.apk时遇到的错误。

I tried to fix it by adding: 我尝试通过添加以下内容来修复它:

-dontwarn com.squareup.picasso.**

in my pro guard-rules.pro file. 在我的pro guard-rules.pro文件中。

The release.apk now builds correctly, at least apparently it does. release.apk现在正确构建,至少显然是这样。

But when I install the app on my phone (or any phone), it crashes at launch, I think when it starts loading the images with Picasso. 但是当我在我的手机(或任何手机)上安装应用程序时,它会在启动时崩溃,我想当它开始用Picasso加载图像时。

Please help me fix this problem. 请帮我解决这个问题。

I have tried some solutions found on the internet and suggested from you, they all seem to build correctly, but the app still keeps crashing. 我已尝试在互联网上找到一些解决方案并向您建议,它们似乎都可以正确构建,但应用程序仍然会崩溃。 Could it depend on something else other than pro guard rules? 除了职业防守规则之外,还能取决于其他什么吗?

This is how my gradle looks like: 这就是我的gradle的样子:

buildTypes {
    release {
        shrinkResources true
        minifyEnabled true
        proguardFile 'proguard-rules.pro'
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }

You seem to be minifying OkHTTP still 你似乎还在缩小OkHTTP

can't find referenced class com.squareup.okhttp

Head over to Picasso's Github page 前往Picasso的Github页面

-dontwarn com.squareup.okhttp.**

try these to your proguard.cfg: 尝试这些你的proguard.cfg:

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

 #### -- OkHttp --

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

 #### -- Apache Commons --

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

try this in your app gradle 在你的应用程序gradle中尝试这个

minifyEnabled false shrinkResources false minifyEnabled false shrinkResources false

my problem was that I could not generate a signed apk with minifyEnabled true and I have fixed it by adding the following to the proguard-rules.pro file: 我的问题是我无法使用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

or you can use the following if the above still causes problems: 或者如果上述问题仍然存在问题,您可以使用以下内容:

#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

解决了在proguard-rules.pro添加此行:

-dontwarn com.squareup.okhttp.**

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将minifyEnabled设置为true时,应用程序崩溃 - App crashes on setting minifyEnabled to true Android - 当 minifyEnabled true 导致 java.lang.ExceptionInInitializerError 时,带有混淆 AAR 库的应用程序崩溃 - Android - App with obfuscated AAR library is crashing when minifyEnabled true causes java.lang.ExceptionInInitializerError Android minifyEnabled = true shrinkResources = true 保持应用程序崩溃 - Android minifyEnabled = true shrinkResources = true keep crashing application 当我使用minifyEnabled app继续崩溃 - when i use minifyEnabled app keep crashing 使用 minifyEnabled true 执行我的应用程序时出现 ClassCastException - ClassCastException while executing my app with minifyEnabled true minifyEnabled true 导致发布应用程序崩溃 - minifyEnabled true causes release app crash TaskExecutionException与minifyEnabled在构建应用程序时为true - TaskExecutionException with minifyEnabled true when building app minifyEnabled true会导致应用启动时崩溃 - minifyEnabled true leads to crash on app start 当 minifyEnabled 为 true 时,Firebase 应用程序崩溃 - Firebase App Crashes when minifyEnabled is true 当 minifyEnabled 为真时,Android 应用程序崩溃 - Android app crashes when minifyEnabled is true
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM