Android/HttpRequest通信/DefaultHttpClient/legacy
提供: 初心者エンジニアの簡易メモ
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/methods/HttpGet;エラーが出る場合
以下追加 app/build.gradle
dependencies { implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.1' }
参考:https://stackoverflow.com/questions/41655015/java-and-httpclient-java-lang-noclassdeffounderror
file was found with OS independent path 'META-INF/DEPENDENCIES'エラーとなる場合は
以下追加 app/build.gradle
android { packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/license.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/notice.txt' exclude 'META-INF/ASL2.0' } }
httpclient defines classes that conflict with classes now provided by Android.エラーとなる場合は
以下追加 app/build.gradle
configurations { all { exclude module: 'httpclient' } }