无法解析符号NameValuePair

g82*_*435 22 java sdk android

在我的项目中,我收到一个错误:

检索项目的父项时出错:找不到与给定名称"android:TextAppearance.Material.Widget.Button.Inverse"匹配的资源.

然后我尝试修复它使用这个:

compileSdkVersion 23
Run Code Online (Sandbox Code Playgroud)

但后来我得到了错误:

无法解析符号NameValuePair android

如何解决这个错误?

Rah*_*rma 33

如果你想在android studio中使用NameValuePairBasicNameValuePair以及最新的API Levels.然后按照以下步骤:

  • 打开build.gradle(Module)文件并复制这些依赖项:

    implementation 'com.google.http-client:google-http-client-android:+'
    
    implementation 'com.google.api-client:google-api-client-android:+'
    
    implementation 'com.google.api-client:google-api-client-gson:+'
    
    Run Code Online (Sandbox Code Playgroud)
  • 复制useLibrary 'org.apache.http.legacy'如下buildToolsVersion:

    android {
    useLibrary 'org.apache.http.legacy'}
    
    Run Code Online (Sandbox Code Playgroud)

就这样.现在只需同步gradle文件.

注意:在依赖项中,我建议使用最新版本的库而不是+符号.


Bla*_*elt 14

NameValuePairorg.apache不推荐使用Android 22和删除的包的一部分Android M,这是针对您正在编译的版本.有趣的是,NameValuePair的文档都不可访问


Däñ*_*rmà 10

今天我也有同样的问题.我解决了build.gradle中的两个更改

 1)   android {
        useLibrary 'org.apache.http.legacy'
              }

2)  compile 'org.apache.httpcomponents:httpcore:4.4.1'
    compile 'org.apache.httpcomponents:httpclient:4.5'
Run Code Online (Sandbox Code Playgroud)

我的最终build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.corouter"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

android {
    useLibrary 'org.apache.http.legacy'
}
dependencies
        {
            compile fileTree(include: ['*.jar'], dir: 'libs')
            testCompile 'junit:junit:4.12'
            compile 'com.android.support:appcompat-v7:23.2.0'
            compile 'com.android.support:recyclerview-v7:23.0.+'
            compile 'org.apache.httpcomponents:httpcore:4.4.1'
            compile 'org.apache.httpcomponents:httpclient:4.5'

        }
Run Code Online (Sandbox Code Playgroud)


小智 5

添加这个:

compile'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
Run Code Online (Sandbox Code Playgroud)

在基于应用程序的 build.gradle 中它会选择它