android代码混淆报错总结:java.io.IOException: Please correct the above

本文解决了Android项目中使用ProGuard进行代码混淆时遇到的错误,特别是针对第三方jar包引用导致的问题。通过在proguard.cfg文件中添加特定配置,如使用-dontwarn参数避免警告,确保了代码混淆过程的顺利进行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://www.cnblogs.com/zfrr/archive/2012/06/01/2530744.html

 

android代码混淆报错总结:java.io.IOException: Please correct the above warnings first

 

[2012-06-01 14:06:03 - geoTest6.3] Warning: org.apache.log4j.lf5.viewer.LogFactor5InputDialog$1: can't find referenced class java.awt.event.KeyAdapter
[2012-06-01 14:06:03 - geoTest6.3] Warning: org.apache.log4j.lf5.viewer.LogFactor5InputDialog$1: can't find referenced class java.awt.event.KeyEvent
[2012-06-01 14:06:03 - geoTest6.3] Warning: org.apache.log4j.lf5.viewer.LogFactor5InputDialog$1: can't find referenced class java.awt.Dialog
[2012-06-01 14:06:03 - geoTest6.3] Warning: org.apache.log4j.lf5.viewer.LogFactor5InputDialog$1: can't find referenced class java.awt.event.KeyAdapter
[2012-06-01 14:06:03 - geoTest6.3] Warning: org.apache.log4j.lf5.viewer.LogFactor5InputDialog$1: can't find referenced class java.awt.event.KeyEvent
[2012-06-01 14:06:03 - geoTest6.3] Warning: org.apache.log4j.lf5.viewer.LogFactor5InputDialog$1: can't find referenced class java.awt.Dialog
[2012-06-01 14:06:03 - geoTest6.3] Warning: org.apache.log4j.lf5.viewer.LogFactor5InputDialog$1: can't find referenced class java.awt.event.KeyEvent
[2012-06-01 14:06:03 - geoTest6.3] Warning: org.apache.log4j.lf5.viewer.LogFactor5InputDialog$1: can't find referenced class java.awt.event.KeyEvent
[2012-06-01 14:06:03 - geoTest6.3]       You should check if you need to specify additional program jars.
[2012-06-01 14:06:03 - geoTest6.3] Warning: there were 1773 unresolved references to classes or interfaces.
[2012-06-01 14:06:03 - geoTest6.3]          You may need to specify additional library jars (using '-libraryjars'),
[2012-06-01 14:06:03 - geoTest6.3]          or perhaps the '-dontskipnonpubliclibraryclasses' option.
[2012-06-01 14:06:03 - geoTest6.3] Warning: there were 1 instances of library classes depending on program classes.
[2012-06-01 14:06:03 - geoTest6.3]          You must avoid such dependencies, since the program classes will
[2012-06-01 14:06:03 - geoTest6.3]          be processed, while the library classes will remain unchanged.
[2012-06-01 14:06:03 - geoTest6.3] java.io.IOException: Please correct the above warnings first.
[2012-06-01 14:06:03 - geoTest6.3]  at proguard.Initializer.execute(Initializer.java:308)
[2012-06-01 14:06:03 - geoTest6.3]  at proguard.ProGuard.initialize(ProGuard.java:210)
[2012-06-01 14:06:03 - geoTest6.3]  at proguard.ProGuard.execute(ProGuard.java:85)
[2012-06-01 14:06:03 - geoTest6.3]  at proguard.ProGuard.main(ProGuard.java:499)
[2012-06-01 14:12:33 - geoTest6.3] Proguard returned with error code 1. See console

解决办法:因为采用了三方的jar包,需要我们在 proguard.cfg 中添加"-dontwarn"

如下:

proguard.cfg 全部配置

-dontwarn 
-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 *;
}

可解决! 

 

### Java接口中的`java.io.IOException: Connection reset by peer`和`Broken pipe`错误解析 当应用程序遭遇`java.io.IOException: Connection reset by peer` 或 `Broken pipe` 错误时,这通常意味着网络连接被远程主机突然关闭或本地尝试向已断开的连接写入数据。此类问题可能源于多种因素,包括但不限于防火墙配置不当、服务器过载、超时设置不合理或是协议版本不兼容等问题。 针对上述两种异常情况,有几种常见的处理方法: #### 修改Tomcat Connector配置以适应高并发场景 对于运行于Apache Tomcat上的应用而言,调整其<Connector>标签内的参数可以有效缓解部分因连接重置引发的问题。例如,将默认使用的HTTP/1.1协议更改为特定实现如`org.apache.coyote.http11.Http11NioProtocol`有助于提高稳定性[^3]: ```xml <Connector port="8760" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000" redirectPort="8443"/> ``` #### 调整Netty代理客户端初始化逻辑 如果项目基于Netty框架构建,则可以在创建管道处理器链的过程中显式指定目标服务端地址信息来规避潜在的风险。具体做法是在调用`context.newHandler()`函数的同时传入远端主机名与端口号作为额外参数[^2]: ```java socketChannel.pipeline().addLast( context.newHandler(socketChannel.alloc(), "targetHost", targetPort)); ``` #### 配置Nginx反向代理相关指令优化 当使用Nginx作为前端负载均衡器或静态资源分发节点时,适当增大缓冲区大小并确保各层缓存机制之间的一致性同样重要。特别是要保证`proxy_busy_buffers_size`不低于最大允许值`proxy_buffer_size`,从而减少由于流量突增造成的连接中断概率[^4]: ```nginx http { ... proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; } ``` 通过以上措施的应用,在很大程度上能够降低甚至消除由`Connection reset by peer` 及 `Broken pipe` 所带来的负面影响。当然,实际操作过程中还需结合具体情况灵活应对,并持续监控系统表现以便及时作出相应调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值