Proguard:Android Studio:找不到符号类ErrorListener,Method,ImageCache

时间:2016-06-17 12:04:05

标签: android android-volley proguard

我是Proguard的新手,我正在我的应用程序中实现它

App-> Module1-> ApIManager-> Volley是依赖图

我正在使用Grale。没有Proguard一切都运行良好。但是对于Proguard,我在上面的三个类用途中得到了错误。

我注意到所有这些都在com.android.volley下并且是接口

我的Proguard.cfg for APImanager和volley是

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
#-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

#---------------------------------------------------------------------------------------------
-renamesourcefileattribute SourceFile
-keepattributes  Signature,SourceFile,LineNumberTable

-keep interface com.android.volley.Response$ErrorListener { *; }
-keep interface com.android.volley.toolbox$ImageLoader { *; }
-keep interface com.android.volley.Request$Method { *; }

-keep public class * extends android.app.Application

-keep class android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep class com.android.volley.** { *; }

-keepattributes *Annotation*


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

构建错误:

:volley:transformClassesAndResourcesWithSyncLibJarsForRelease
:volley:mergeReleaseJniLibFolders UP-TO-DATE
:volley:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
:volley:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
:volley:bundleRelease
:apimanager:prepareComAndroidSupportAnimatedVectorDrawable2340Library UP-TO-DATE
:apimanager:prepareComAndroidSupportAppcompatV72340Library UP-TO-DATE
:apimanager:prepareComAndroidSupportSupportV42340Library UP-TO-DATE
:apimanager:prepareComAndroidSupportSupportVectorDrawable2340Library UP-TO-DATE
:apimanager:prepareComAndroidVolleyVolleyUnspecifiedLibrary
:apimanager:prepareReleaseDependencies
:apimanager:compileReleaseAidl UP-TO-DATE
:apimanager:compileReleaseRenderscript UP-TO-DATE
:apimanager:generateReleaseBuildConfig UP-TO-DATE
:apimanager:mergeReleaseShaders UP-TO-DATE
:apimanager:compileReleaseShaders UP-TO-DATE
:apimanager:generateReleaseAssets UP-TO-DATE
:apimanager:mergeReleaseAssets UP-TO-DATE
:apimanager:generateReleaseResValues UP-TO-DATE
:apimanager:generateReleaseResources UP-TO-DATE
:apimanager:mergeReleaseResources UP-TO-DATE
:apimanager:processReleaseManifest UP-TO-DATE
:apimanager:processReleaseResources UP-TO-DATE
:apimanager:generateReleaseSources UP-TO-DATE
:apimanager:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:apimanager:compileReleaseJavaWithJavac
:apimanager:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
--Path--\apimanager\APIManager.java
Error:(124, 105) error: cannot find symbol class ErrorListener
Error:(133, 107) error: cannot find symbol class ErrorListener
Error:(50, 32) error: cannot find symbol class ImageCache
Error:(66, 32) error: cannot find symbol class ImageCache
--Path--\apimanager\CategoryRequest.java
Error:(24, 82) error: cannot find symbol class ErrorListener
Error:(25, 15) error: cannot find symbol variable Method
--Path--\apimanager\ProductRequest.java
Error:(32, 80) error: cannot find symbol class ErrorListener
Error:(33, 15) error: cannot find symbol variable Method
:apimanager:compileReleaseJavaWithJavac FAILED
Error:Execution failed for task ':apimanager:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED

代码在没有proguard的情况下运行正常,我已经尝试了几乎所有内容并且在没有帮助的情况下也经历了很多教程。

1 个答案:

答案 0 :(得分:0)

将ProGuard应用于多项目构建中的库项目时,应在gradle中使用以下指令指定使用的规则:

consumerProguardFiles('...')

通过这种方式,它们也将自动包含在消费应用程序项目中,并将应用所需的保留规则。