为何在ProGuard中禁用混淆会中断优化步骤?

为何在ProGuard中禁用混淆会中断优化步骤?,第1张

概述我们最近决定在我们的Android版本中禁用代码混淆功能,因为虽然它使最终的APK稍大,但调试起来却非常困难.自从这样做以来,我一直遇到应用程序崩溃的情况,这些崩溃以前是不存在的,即混淆仍然处于活动状态.通常,这些崩溃是由JavaVerifyErrors或NoSuchMethodErrors引起的.禁用混淆时

我们最近决定在我们的Android版本中禁用代码混淆功能,因为虽然它使最终的APK稍大,但调试起来却非常困难.

自从这样做以来,我一直遇到应用程序崩溃的情况,这些崩溃以前是不存在的,即混淆仍然处于活动状态.通常,这些崩溃是由Java VerifyErrors或NoSuchMethodErrors引起的.

禁用混淆时,我突然看到以下两个错误:

Could not find method org.apache.http.httpconnectionMetrics.getResponseCount, referenced from method com.Google.androID.apps.analytics.PipelinedRequester.sendRequestsW/dalvikvm( 6652): VFY: unable to resolve virtual method 16112: Lorg/apache/http/httpconnectionMetrics;.getResponseCount ()JW/dalvikvm( 6652): VFY:  rejecting opcode 0x6e at 0x000cW/dalvikvm( 6652): VFY:  rejected Lcom/Google/androID/apps/analytics/PipelinedRequester;.sendRequests ()VW/dalvikvm( 6652): VerifIEr rejected class Lcom/Google/androID/apps/analytics/PipelinedRequester;D/dalvikvm( 6652): GC_CONCURRENT freed 253K, 46% free 3261K/6023K, external 0K/0K, paused 2ms+2msI/dalvikvm( 6652): Rejecting re-init on prevIoUsly-Failed class Lcom/Google/androID/apps/analytics/PipelinedRequester; v=0x4062de30D/AndroIDRuntime( 6652): Shutting down VMW/dalvikvm( 6652): threadID=1: thread exiting with uncaught exception (group=0x400a7560)E/AndroIDRuntime( 6652): FATAL EXCEPTION: mainE/AndroIDRuntime( 6652): java.lang.VerifyError: com/Google/androID/apps/analytics/PipelinedRequester... 

我可以通过!class / merging / *禁用类合并来解决此错误

我看到的另一个错误是:

I/dalvikvm( 7292): DexOpt: access denIEd from Lcom/urbanairship/analytics/EventUploadManager; to fIEld Lorg/apache/http/entity/Abstracthttpentity;.contentEnCodingW/dalvikvm( 7292): VFY: unable to resolve instance fIEld 5188D/dalvikvm( 7292): VFY: replacing opcode 0x5b at 0x00ecI/dalvikvm( 7292): Could not find method org.apache.http.conn.scheme.PlainSocketFactory.<init>, referenced from method com.Google.androID.apps.analytics.PipelinedRequester.<init>W/dalvikvm( 7292): VFY: unable to resolve direct method 15044: Lorg/apache/http/conn/scheme/PlainSocketFactory;.<init> (B)VD/dalvikvm( 7292): VFY: replacing opcode 0x70 at 0x0003D/dalvikvm( 7292): VFY: dead code 0x0006-0009 in Lcom/Google/androID/apps/analytics/PipelinedRequester;.<init> (Lorg/apache/http/httpHost;)VI/dalvikvm( 7292): DexOpt: access denIEd from Lcom/Google/androID/apps/analytics/PipelinedRequester; to fIEld Lorg/apache/http/impl/SockethttpClIEntConnection;.openW/dalvikvm( 7292): VFY: unable to resolve instance fIEld 5234D/dalvikvm( 7292): VFY: replacing opcode 0x55 at 0x0006D/dalvikvm( 7292): VFY: dead code 0x0008-000e in Lcom/Google/androID/apps/analytics/PipelinedRequester;.closeConnection ()VD/dalvikvm( 7292): VFY: dead code 0x0010-0011 in Lcom/Google/androID/apps/analytics/PipelinedRequester;.closeConnection ()VI/dalvikvm( 7292): DexOpt: access denIEd from Lcom/Google/androID/apps/analytics/PipelinedRequester; to fIEld Lorg/apache/http/impl/SockethttpClIEntConnection;.openW/dalvikvm( 7292): VFY: unable to resolve instance fIEld 5234D/dalvikvm( 7292): VFY: replacing opcode 0x55 at 0x0006D/dalvikvm( 7292): VFY: dead code 0x0008-0009 in Lcom/Google/androID/apps/analytics/PipelinedRequester;.addRequest (Lorg/apache/http/httpentityEnclosingRequest;)VD/dalvikvm( 7292): GC_CONCURRENT freed 253K, 47% free 3251K/6023K, external 0K/0K, paused 2ms+3msI/dalvikvm( 7292): DexOpt: access denIEd from Lcom/Google/androID/apps/analytics/PipelinedRequester; to fIEld Lorg/apache/http/impl/AbstracthttpClIEntConnection;.metricsW/dalvikvm( 7292): VFY: unable to resolve instance fIEld 5225D/dalvikvm( 7292): VFY: replacing opcode 0x54 at 0x0008D/dalvikvm( 7292): VFY: dead code 0x000a-0090 in Lcom/Google/androID/apps/analytics/PipelinedRequester;.sendRequests ()VD/AndroIDRuntime( 7292): Shutting down VMW/dalvikvm( 7292): threadID=1: thread exiting with uncaught exception (group=0x400a7560)E/AndroIDRuntime( 7292): FATAL EXCEPTION: mainE/AndroIDRuntime( 7292): java.lang.NoSuchMethodError: org.apache.http.conn.scheme.PlainSocketFactory.<init>

我可以通过设置!method / propagation / *来解决这一问题

但是,为什么这些问题仅在禁用混淆后才会出现?一个人不应该对另一个人没有影响吗?

解决方法:

混淆使您免于因为您将Apache httpClIEnt类的副本重命名为不会与这些类的副本already present in Android相冲突的名称.

令人讨厌的地方…您可能要考虑完全不使用Apache httpClIEnt,而是使用Jesse Wilson建议的内置HttpURLConnection类:

http://android-developers.blogspot.com/2011/09/androids-http-clients.html

您可以在httpURLConnection上尝试使用此AndroID友好的贴面:

https://github.com/kevinsawicki/http-request

如果确实需要使用Apache httpClIEnt,请使用嵌入在AndroID中的旧版本,或者尝试调整ProGuard配置以混淆httpClIEnt库.

总结

以上是内存溢出为你收集整理的为何在ProGuard中禁用混淆会中断优化步骤?全部内容,希望文章能够帮你解决为何在ProGuard中禁用混淆会中断优化步骤?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1085893.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存