为什么警告:无法找到可选库:org.apache.http.legacy发生?

irw*_*wan 30 android apache-commons-httpclient

我的gradle文件:

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 
} 
Run Code Online (Sandbox Code Playgroud)

我明白了 Warning:Unable to find optional library: org.apache.http.legacy

Vit*_*con 78

我想,在不必重新安装SDK的情况下解决此问题的更简单方法是使用以下内容创建一个名为optional.jsonin <sdk-path>\platforms\android-23\optional\directory 的文件:

[
  {
    "name": "org.apache.http.legacy",
    "jar": "org.apache.http.legacy.jar",
    "manifest": false
  }
]
Run Code Online (Sandbox Code Playgroud)

它解决了我的问题.


编辑:从@ domoch的答案中获取的有关如何找到SDK位置的信息

查找Android SDK的位置

转到Android Studio Settings -> Appearence & Behavior -> System Settings并查找Android SDK Location.在Windows中,它通常会指向C:\Users\<username>\AppData\Local\Android\sdk.


pra*_*att 26

我有完全相同的问题.请检查您是否有android-sdk-windows\platforms\android-23\optional\optional.json文件.如果没有,那么只需重新安装API 23(删除并重新安装).