java.lang.NoSuchMethodError: No virtual method getSchemeSocketFactory()Lorg/apache/http/conn/scheme/

华为和荣耀 手机9.0系统,程序第一次可以运行,后续启动后白屏,一直报这个错误

java.lang.NoSuchMethodError: No virtual method getSchemeSocketFactory()Lorg/apache/http/conn/scheme/SchemeSocketFactory; in class Lorg/apache/http/conn/scheme/Scheme; or its super classes (declaration of 'org.apache.http.conn.scheme.Scheme' appears in /system/framework/org.apache.http.legacy.boot.jar)
        at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:128)
        at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
        at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
        at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:596)
    	at org.apache.http.impl.client.AbstractHttpClient.execute(Abstract

原因:
google在5.x对httpclient进行了移除

解决:
在build.gradle文件加上

android {
    useLibrary 'org.apache.http.legacy'
}

你可能感兴趣的:(android学习)