Picasso和httpClient无法解析

时间:2016-02-01 10:24:23

标签: android android-studio gradle build android-gradle

以前有人遇到过这个问题吗? Picasso和httpClient无法解析。

Gradle Build Error

  

错误:配置根项目' app'。

时出现问题      
    

无法解析配置的所有依赖项':_ debugCompile'。     找不到org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2。          在以下位置搜索:              文件:/ C:/Users/tongws/AppData/Local/Android/sdk/extras/android/m2repository/org/jbundle/util/osgi/wrapped/org.jbundle.util.osgi.wrapped.org.apache.http。客户机/ 4.1.2 / org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.pom              文件:/ C:/Users/tongws/AppData/Local/Android/sdk/extras/android/m2repository/org/jbundle/util/osgi/wrapped/org.jbundle.util.osgi.wrapped.org.apache.http。客户机/ 4.1.2 / org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar              文件:/ C:/Users/tongws/AppData/Local/Android/sdk/extras/google/m2repository/org/jbundle/util/osgi/wrapped/org.jbundle.util.osgi.wrapped.org.apache.http。客户机/ 4.1.2 / org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.pom              文件:/ C:/Users/tongws/AppData/Local/Android/sdk/extras/google/m2repository/org/jbundle/util/osgi/wrapped/org.jbundle.util.osgi.wrapped.org.apache.http。客户机/ 4.1.2 / org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar          要求:              :应用程序:未指定     找不到com.squareup.picasso:picasso:2.4.0。          在以下位置搜索:              文件:/ C:/Users/tongws/AppData/Local/Android/sdk/extras/android/m2repository/com/squareup/picasso/picasso/2.4.0/picasso-2.4.0.pom              文件:/ C:/Users/tongws/AppData/Local/Android/sdk/extras/android/m2repository/com/squareup/picasso/picasso/2.4.0/picasso-2.4.0.jar              文件:/ C:/Users/tongws/AppData/Local/Android/sdk/extras/google/m2repository/com/squareup/picasso/picasso/2.4.0/picasso-2.4.0.pom              文件:/ C:/Users/tongws/AppData/Local/Android/sdk/extras/google/m2repository/com/squareup/picasso/picasso/2.4.0/picasso-2.4.0.jar          要求:              :应用程序:未指定的

  

Gradle Sync

Error:Failed to resolve: com.squareup.picasso:picasso:2.4.0
<a href="openFile">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:(25, 13) Failed to resolve: org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2
<a href="openFile">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Information:The project encoding (windows-1252) has been reset to the encoding specified in the Gradle build files (UTF-8).
Mismatching encodings can lead to serious bugs.
<a href="http://tools.android.com/knownissues/encoding">More Info...</a>

的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"


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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    compile "com.squareup.picasso:picasso:2.4.0"
}

buildscript {
    repositories {
        jcenter() // or mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}

被修改

apply plugin: 'com.android.application'

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


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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'

}


buildscript {
    repositories {
        jcenter() // or mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}

Gradle Sync错误

Error:(26, 13) Failed to resolve: org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2
<a href="openFile">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

Gradle Build Error

Error:A problem occurred configuring root project 'app'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not find org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2.
     Searched in the following locations:
         file:/C:/Users/tongws/AppData/Local/Android/sdk/extras/android/m2repository/org/jbundle/util/osgi/wrapped/org.jbundle.util.osgi.wrapped.org.apache.http.client/4.1.2/org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.pom
         file:/C:/Users/tongws/AppData/Local/Android/sdk/extras/android/m2repository/org/jbundle/util/osgi/wrapped/org.jbundle.util.osgi.wrapped.org.apache.http.client/4.1.2/org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar
         file:/C:/Users/tongws/AppData/Local/Android/sdk/extras/google/m2repository/org/jbundle/util/osgi/wrapped/org.jbundle.util.osgi.wrapped.org.apache.http.client/4.1.2/org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.pom
         file:/C:/Users/tongws/AppData/Local/Android/sdk/extras/google/m2repository/org/jbundle/util/osgi/wrapped/org.jbundle.util.osgi.wrapped.org.apache.http.client/4.1.2/org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar
     Required by:
         :app:unspecified

3 个答案:

答案 0 :(得分:0)

在您的构建gradle中添加 useLibrary&#39; org.apache.http.legacy&#39;

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

答案 1 :(得分:0)

HttpClient正在被描述以便更好地使用Volley或者你也可以访问okhttp,顺便说一句如果你仍然想要使用http客户端那么有选项只需你必须在你的android块中包含遗留在graddle app文件中

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

毕加索使用网络服务所以一旦你解决了这个毕加索将正常工作,有关毕加索的详细信息,请访问

https://www.simplifiedcoding.net/picasso-android-tutorial-picasso-image-loader-library/

答案 2 :(得分:0)

可能有两个问题: 1)在/project/build.gradle中添加它

   allprojects {
        repositories {
            jcenter()
        }    
}

2)你可以做上面提到的

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