【问题标题】:Proguard-rules.pro failed while removing logs in relese apk AndroidProguard-rules.pro 在删除版本 apk Android 中的日志时失败
【发布时间】:2017-06-01 05:25:51
【问题描述】:
   ProGuard, version 5.2.1
    Note: the configuration specifies that none of the methods of class 'android.util.Log' have any side effects
    : 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
    Note: com.google.android.gms.internal.zzast: can't find dynamically referenced class android.os.SystemProperties
    Note: com.squareup.picasso.Utils: can't find dynamically referenced class com.squareup.okhttp.OkHttpClient
    Note: com.google.android.gms.dynamite.DynamiteModule accesses a declared field 'MODULE_ID' dynamically
          Maybe this is program field 'com.google.android.gms.dynamite.descriptors.com.google.android.gms.flags.ModuleDescriptor { java.lang.String MODULE_ID; }'
    Note: com.google.android.gms.dynamite.DynamiteModule accesses a declared field 'MODULE_VERSION' dynamically
          Maybe this is program field 'com.google.android.gms.dynamite.descriptors.com.google.android.gms.flags.ModuleDescriptor { int MODULE_VERSION; }'
    Note: com.google.android.gms.dynamite.DynamiteModule accesses a declared field 'sClassLoader' dynamically
          Maybe this is program field 'com.google.android.gms.dynamite.DynamiteModule$DynamiteLoaderClassLoader { java.lang.ClassLoader sClassLoader; }'
    Note: the configuration keeps the entry point 'com.google.android.gms.ads.identifier.AdvertisingIdClient { com.google.android.gms.internal.zzcn zza(android.content.Context,com.google.android.gms.common.zza); }', but not the descriptor class 'com.google.android.gms.common.zza'
    Note: the configuration keeps the entry point 'com.google.android.gms.flags.impl.FlagProviderImpl { void init(com.google.android.gms.dynamic.zzd); }', but not the descriptor class 'com.google.android.gms.dynamic.zzd'
    Note: the configuration keeps the entry point 'com.google.android.gms.measurement.AppMeasurement { void registerOnScreenChangeCallback(com.google.android.gms.measurement.AppMeasurement$zzd); }', but not the descriptor class 'com.google.android.gms.measurement.AppMeasurement$zzd'
    Note: the configuration keeps the entry point 'com.google.android.gms.measurement.AppMeasurement { void unregisterOnScreenChangeCallback(com.google.android.gms.measurement.AppMeasurement$zzd); }', but not the descriptor class 'com.google.android.gms.measurement.AppMeasurement$zzd'
    Note: the configuration keeps the entry point 'com.google.firebase.iid.FirebaseInstanceId { com.google.firebase.iid.FirebaseInstanceId getInstance(com.google.firebase.FirebaseApp); }', but not the descriptor class 'com.google.firebase.FirebaseApp'
    Note: the configuration keeps the entry point 'com.sothree.slidinguppanel.SlidingUpPanelLayout { void setScrollableViewHelper(com.sothree.slidinguppanel.ScrollableViewHelper); }', but not the descriptor class 'com.sothree.slidinguppanel.ScrollableViewHelper'
    Note: the configuration keeps the entry point 'com.sothree.slidinguppanel.SlidingUpPanelLayout { void setPanelState(com.sothree.slidinguppanel.SlidingUpPanelLayout$PanelState); }', but not the descriptor class 'com.sothree.slidinguppanel.SlidingUpPanelLayout$PanelState'
    Note: the configuration keeps the entry point 'com.sothree.slidinguppanel.SlidingUpPanelLayout { void setPanelStateInternal(com.sothree.slidinguppanel.SlidingUpPanelLayout$PanelState); }', but not the descriptor class 'com.sothree.slidinguppanel.SlidingUpPanelLayout$PanelState'
    Note: there were 2 references to unknown classes.
          You should check your configuration for typos.
          (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
    Note: there were 3 classes trying to access generic signatures using reflection.
          You should consider keeping the signature attributes
          (using '-keepattributes Signature').
          (http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
    Note: there were 8 unkept descriptor classes in kept class members.
          You should consider explicitly keeping the mentioned classes
          (using '-keep').
          (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
    Note: there were 2 unresolved dynamic references to classes or interfaces.
          You should check if you need to specify additional program jars.
          (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
    Note: there were 3 accesses to class members by means of introspection.
          You should consider explicitly keeping the mentioned class members
          (using '-keep' or '-keepclassmembers').
          (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)
    Warning:there were 318 unresolved references to classes or interfaces.
             You may need to add missing library jars or update their versions.
             If your code works fine without the missing classes, you can suppress
             the warnings with '-dontwarn' options.
             (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
    Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
    :app:transformClassesAndResourcesWithProguardForRelease FAILED
    Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
    > java.io.IOException: Please correct the above warnings first.
    Information:BUILD FAILED
    Information:Total time: 4.766 secs
    Information:1 error
    Information:200 warnings
    Information:See complete output in console


   My proguard-rules.pro file is:
# Disable Android logging
-dontskipnonpubliclibraryclasses
-dontobfuscate
-forceprocessing
-optimizationpasses 5
-dontwarn okio.**
-dontwarn android.support.**
-dontnote android.support.**
-dontwarn org.apache.http.**
-dontwarn org.apache.lang.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.google.android.gms.**
-dontwarn com.android.volley.toolbox.**
-keepclassmembers class * implements android.os.Parcelable {
    static ** CREATOR;
}
-keep class * extends android.app.Activity

-assumenosideeffects class android.util.Log {*;}

我添加了此代码以从 app-release apk 中删除日志并收到类似 IOException 的错误,在此请先更正上述警告。我不知道如何纠正这个警告。我参考了很多链接,但我仍然无法解决它。

【问题讨论】:

    标签: android proguard


    【解决方案1】:

    你可以把它写在 proguard.pro 文件中。

    -dontwarn com.squareup.**
    -dontnote com.squareup.**
    

    【讨论】:

    • 仍然有错误..请帮助我。谢谢您的回答..我发布下一个问题是错误请找到它..
    • 写入同一行以删除 progaurd.pro 文件中带有包名的所有警告和注释。像这样 -dontwarn com.dropbox.**
    • 谢谢 Rims ..它对我有用..现在没有警告..但问题仍然是我可以看到发布 apk 中的日志..我可以做些什么来删除发布中的所有日志apk??你能给我一些帮助吗??
    • -assumenosideeffects class android.util.Log { public static *** d(...);公共静态 *** w(...);公共静态 *** v(...);公共静态 *** i(...); }
    • 我将此行添加到我的 proguard-rules.pro 文件中:-assumenosideeffects class android.util.Log { public static *** d(...);公共静态 *** w(...);公共静态 *** v(...);公共静态 *** i(...);公共静态 *** e(...); } 但仍显示 D 和 E..的日志。
    猜你喜欢
    • 2014-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-05
    • 2021-11-22
    • 1970-01-01
    相关资源
    最近更新 更多