最近,碰到一个需要使用Aether包来在安卓App内下载jar的需求,在IDEA上实现了,没有任何问题,但是在安卓上却遇到了异常:
java.lang.NoSuchMethodError:No direct method <init>(Ljavax/net/ssl/SSLSocketFactory;Lorg/apache/http/conn/ssl/X509HostnameVerifier;)V in class Lorg/apache/http/conn/ssl/SSLSocketFactory; or its super classes(declaration of 'org.apache.http.conn.ssl.SSLSocketFactory' appears in /system/framework/framework.jar!classes3.dex)
framework/framework.jar!classes3.dex)
at org.eclipse.aether.transport.http.SslSocketFactory.<init(SslSocketFactory.java:57)
...
原来是org.eclipse.aether.transport.http.SslSocketFactory的构造方法里面出现问题了,我们顺藤摸瓜看看为啥:
(在Android Studio内,切换到Project工程结构展示,展开External Libraries,进入org.eclipse.aether.transport-http包内查找)
org.eclipse.aether.transport.http.SslSocketFactory文件内容:
final class SslSocketFactory
extends org.apache.http.conn.ssl.SSLSocketFactory
{
...
private SslSocketFactory( SSLSocketFactory socketfactory, X509HostnameVerifier hostnameVerifier,
String[] cipherSuites, String[] protocols )
{
super( socketfactory, hostnameVerifier );
this.cipherSuites = cipherSuites;
this.protocols = protocols;
}
...
}
在AS内可以看到这里已经显示报错了:
同理,进入父类中看看为什么:
发现原来根本没有这个构造方法,我便查了相关的资料:
而,这个需求无法使用legacy包解决, 我只好另外想办法。
JarFilter:Jar包文件替换插件
在无奈中,发现了[Github]JarFilter<