Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
434 views
in Technique[技术] by (71.8m points)

android - Why Warning:Unable to find optional library: org.apache.http.legacy occurs?

My gradle file:

apply plugin: 'com.android.application' 

android { 
  useLibrary 'org.apache.http.legacy' 
  compileSdkVersion 23 
  buildToolsVersion "23.0.0" 

  defaultConfig { 
    applicationId "com.skripsi.irwanto.paud" 
    minSdkVersion 15 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
  } 

  buildTypes { 
    release { 
      minifyEnabled false 
      proguardFiles getDefaultProauardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
  } 
} 
dependencies { 
 compile fileTree(include: ['*.jar'], dir: 'libs') 
 testCompile 'junit:junit:4.12' 
 compile 'com.android.support:appcompat-v7:23.1.11 
} 

And I get Warning:Unable to find optional library: org.apache.http.legacy

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I guess, the easier way to solve this issue without having to reinstall the SDK is to create a file called optional.json in <sdk-path>platformsandroid-23optional directory with the following content:

[
  {
    "name": "org.apache.http.legacy",
    "jar": "org.apache.http.legacy.jar",
    "manifest": false
  }
]

It solved the problem for me.


EDIT: Information taken from @domoch's answer below on how to locate your SDK location

To Locate your Android SDK's Location

Go to Android Studio Settings -> Appearence & Behavior -> System Settings and look for Android SDK Location. In Windows, it usually would be pointing to C:Users<username>AppDataLocalAndroidsdk.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...