2019년 4월 2일 화요일

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/message/HeaderGroup 에러 해법

  • 안드로이드 SDK가 Pie로 업그레이드 된 폰에서 다음과 같은 에러가 발생할 경우 대처 법
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/message/HeaderGroup

(1) 앱 수준의 build.gradle의 targetSdkVersion을 28로 된 것을 27로 변경해 준다. 28에서 발생하는 문제이다. Api Level 28은 Pie(Android version 9)이고 27은 Oreo(Android version 8.1)이다. 

(2) Manifest.xml의 <application> 속성 아래에 다음 코드를 추가한다.
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

   <uses-library android:name=“org.apache.http.legacy” android:required=“false” />

…. />

구글의 설명을 들어보면 play-service map을 사용할때 발생하는 문제로 설명되어 있다.

If you are using com.google.android.gms:play-services-maps:16.0.0 or below and your app is targeting API level 28 (Android 9.0) or above, you must include the following declaration within the <application> element ofAndroidManifest.xml.

  <uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />
This is handled for you if you are using com.google.android.gms:play-services-maps:16.1.0 and is not necessary if your app is targeting a lower API level.

댓글 없음:

댓글 쓰기