Proguard打包混淆報錯:can't find superclass or interface


在Eclipse打包工程時報如下錯誤:

[2016-04-01 16:36:10 - bjjwcjgc] Proguard returned with error code 1. See console
[2016-04-01 16:36:10 - bjjwcjgc] Note: there were 4 duplicate class definitions.
[2016-04-01 16:36:10 - bjjwcjgc] (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.PermissionCacheOptimizer: can't find superclass or interface org.springframework.aop.framework.AopInfrastructureBean
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.PermissionEvaluator: can't find superclass or interface org.springframework.aop.framework.AopInfrastructureBean
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.SecurityMetadataSource: can't find superclass or interface org.springframework.aop.framework.AopInfrastructureBean
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.event.AbstractAuthorizationEvent: can't find superclass or interface org.springframework.context.ApplicationEvent
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.event.LoggerListener: can't find superclass or interface org.springframework.context.ApplicationListener
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.expression.AbstractSecurityExpressionHandler: can't find superclass or interface org.springframework.context.ApplicationContextAware
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.expression.SecurityExpressionHandler: can't find superclass or interface org.springframework.aop.framework.AopInfrastructureBean
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.expression.method.MethodSecurityEvaluationContext: can't find superclass or interface org.springframework.expression.spel.support.StandardEvaluationContext
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.AbstractSecurityInterceptor: can't find superclass or interface org.springframework.beans.factory.InitializingBean
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.AbstractSecurityInterceptor: can't find superclass or interface org.springframework.context.ApplicationEventPublisherAware
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.AbstractSecurityInterceptor: can't find superclass or interface org.springframework.context.MessageSourceAware
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.AfterInvocationProviderManager: can't find superclass or interface org.springframework.beans.factory.InitializingBean
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.MethodInvocationPrivilegeEvaluator: can't find superclass or interface org.springframework.beans.factory.InitializingBean
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.RunAsImplAuthenticationProvider: can't find superclass or interface org.springframework.beans.factory.InitializingBean
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.RunAsImplAuthenticationProvider: can't find superclass or interface org.springframework.context.MessageSourceAware
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.RunAsManagerImpl: can't find superclass or interface org.springframework.beans.factory.InitializingBean
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor: can't find superclass or interface org.aopalliance.intercept.MethodInterceptor
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor: can't find superclass or interface org.springframework.aop.support.AbstractPointcutAdvisor
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor: can't find superclass or interface org.springframework.beans.factory.BeanFactoryAware
[2016-04-01 16:36:10 - bjjwcjgc] Warning: org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor$MethodSecurityMetadataSourcePointcut: can't find superclass or interface org.springframework.aop.support.StaticMethodMatcherPointcut

[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.content.Intent depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.content.IntentFilter depends on program class org.xmlpull.v1.XmlSerializer
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.content.IntentFilter depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.content.res.ColorStateList depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.graphics.drawable.ColorDrawable depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.graphics.drawable.GradientDrawable depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.graphics.drawable.InsetDrawable depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.graphics.drawable.LayerDrawable depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.graphics.drawable.ShapeDrawable depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.graphics.drawable.ShapeDrawable depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser
[2016-04-01 16:36:10 - bjjwcjgc] Warning: there were 910 unresolved references to classes or interfaces.
[2016-04-01 16:36:10 - bjjwcjgc] You may need to add missing library jars or update their versions.
[2016-04-01 16:36:10 - bjjwcjgc] If your code works fine without the missing classes, you can suppress
[2016-04-01 16:36:10 - bjjwcjgc] the warnings with '-dontwarn' options.
[2016-04-01 16:36:10 - bjjwcjgc] (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
[2016-04-01 16:36:10 - bjjwcjgc] Warning: there were 16 instances of library classes depending on program classes.
[2016-04-01 16:36:10 - bjjwcjgc] You must avoid such dependencies, since the program classes will
[2016-04-01 16:36:10 - bjjwcjgc] be processed, while the library classes will remain unchanged.
[2016-04-01 16:36:10 - bjjwcjgc] (http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)
[2016-04-01 16:36:10 - bjjwcjgc] Warning: there were 12 unresolved references to program class members.
[2016-04-01 16:36:10 - bjjwcjgc] Your input classes appear to be inconsistent.
[2016-04-01 16:36:10 - bjjwcjgc] You may need to recompile the code.
[2016-04-01 16:36:10 - bjjwcjgc] (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
[2016-04-01 16:36:10 - bjjwcjgc] java.io.IOException: Please correct the above warnings first.
[2016-04-01 16:36:10 - bjjwcjgc] at proguard.Initializer.execute(Initializer.java:473)
[2016-04-01 16:36:10 - bjjwcjgc] at proguard.ProGuard.initialize(ProGuard.java:222)
[2016-04-01 16:36:10 - bjjwcjgc] at proguard.ProGuard.execute(ProGuard.java:97)
[2016-04-01 16:36:10 - bjjwcjgc] at proguard.ProGuard.main(ProGuard.java:507)

大體意思是找不到相關的類或者方法,因為工程引入了第三方包,混淆的時候如果把第三方包也混淆了,那么相關的類在使用這些包的時候就會找不到相關方法。

因此在proguard-project.txt加上以下代碼:

-dontwarn org.springframework.security.**
-keep class org.springframework.security.** { *;}

-dontwarn org.xmlpull.v1.**
-keep class org.xmlpull.v1.** { *;}

其實找不到引用的這個類是第三方包里面的,而且很多時候我們只需要打亂自己的代碼就行了,第三方包的代碼就是否要打亂就不要管了。我們可以使用

-dontwarn com.xx.bbb.**
-keep class com.xx.bbb.** { *;}

參數來保持第三方庫中的類而不亂,-dontwarn和-keep 結合使用,意思是保持com.xx.bbb.**這個包里面的所有類和所有方法而不混淆,接着還叫ProGuard不要警告找不到com.xx.bbb.**這個包里面的類的相關引用。
配置好后,重新打包,一切OK!而且程序能正確運行


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM