android { compileSdkVersion 28 buildToolsVersion "28.0.1" useLibrary 'org.apache.http.legacy' //添加这一句可解决问题,本人亲测有效 defaultConfig { applicationId "com.example.administrator.testz" minSdkVersion 15 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" }
原因竟是因为:
Android 6.0 release removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the HttpURLConnection class instead. This API is more efficient because it reduces network use through transparent compression and response caching, and minimizes power consumption. To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:
因为大家的studio版本过高,谷歌在android6.0以后删除了这