1
votes

I have started using Android Studio 1.0.2 and I am trying to add Library dependency. For example I am adding loopj library in my project.

Steps which I follow:

File > Project Structure > Module(app) > Dependencies tab > Click on + icon > select loopj library > Apply > OK

Now I am getting issue of Gradle project sync failed. Message : Failed to find: com.loopj.android:android-async-http:1.4.6

Somebody else facing the same problem? Please provide me suggestion if any.

Other information

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.test.testapplication"
        minSdkVersion 14
        targetSdkVersion 21
        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:21.0.3'
    compile 'com.loopj.android:android-async-http:1.4.6'
}

//

buildscript {
    repositories {
        jcenter()
       mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

//

distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip

1
first check gradle version, android plugin version, dependencies repository sources ... in other words provide all gradle files and gradle-wrapper.properties file here ... without this question is off-topic Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce itSelvin
I already checked gradle version, that is 2.2.1 and dependencies : classpath 'com.android.tools.build:gradle:1.0.0'kalpana c
now question contains all information :) ... i bet that problem is mavenCenter ... i think it should be mavenCentral()Selvin
Updated but issue is samekalpana c
@Chris, the Project Structure dialog just modifies the build.gradle files -- your instructions about undoing changes there but then making sure the statements are in the build files doesn't really make sense.Scott Barta

1 Answers

0
votes

I've faced the same problem. The solution was simple, all you need is upgrade your gradle version. To do this, open your build.gradle (root project) and edit the next line:

classpath 'com.android.tools.build:gradle:1.0.0'

to

classpath 'com.android.tools.build:gradle:1.1.0'

So if you are using Android Studio you will notice that you are using offline mode that's not available in the new gradle version. Confirm the change and now you can download the dependencies you want.