简体   繁体   中英

Unable to sync Android Studio with Maven repository

I'm trying to add this libraries to my project:

But Android Studio is returning this errors:

Error:(8, 13) Failed to resolve: com.github.castorflex.smoothprogressbar:library:1.1.0

Error:(6, 13) Failed to resolve: com.loopj.android:android-async-http:1.4.6

Error:(7, 13) Failed to resolve: com.google.apis:google-api-services-analytics:v3-rev115-1.20.0

This is my build.grade file:

apply plugin: 'com.android.application'


dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':librarySmartHotel')
    compile 'com.loopj.android:android-async-http:1.4.6'
    compile 'com.google.apis:google-api-services-analytics:v3-rev115-1.20.0'
    compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
    compile 'com.google.android.gms:play-services:6.5.87'
}

android {
    compileSdkVersion 19
    buildToolsVersion "22.0.1"

    defaultConfig {
        multiDexEnabled true
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

Do I have to configure something?? for example com.google.android.gms:play-services:6.5.87 is working perfect and I have not done any configuration.

Any help will be appreciated.

Firstly try to add to your Project build.gradle file following code or just add it to existent repositories

repositories {
        mavenCentral()
    }

Also you may have "Offline mode" enabled. Check if File -> Build,Execution,Deployment-> Maven/Gradle "Offline work" is enabled, if so just disable it and Sync Gradle

And let me know results.

The Gradle builds which you mentioned perfectly compiled with mine. I suggest you to clean your project and restart android studio and try once again. Please let us know if the problem persists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM