简体   繁体   English

我的Android Studio Gradle无法从Maven Central获取插件

[英]My Android Studio Gradle is not getting the plugin from maven central

I tried to add smoothprogressbar library to my android project 我试图将smoothprogressbar库添加到我的android项目中

I added these lines to my build.gradle 我将这些行添加到build.gradle中

dependencies {
    // of course, do not write x.x.x but the version number
    compile 'com.github.castorflex.smoothprogressbar:library:0.5.2'
}

And when i sync the gradle its saying that Failed to find : com.github.castorflex.smoothprogressbar:library:0.5.1 当我同步gradle时,它的说法是找不到:com.github.castorflex.smoothprogressbar:library:0.5.1

I tried putting mavenCentral() and maven url in build.gradle and other solutions which i found in stackoverflow but nothing seems to work. 我试图将mavenCentral()和maven url放入build.gradle和我在stackoverflow中发现的其他解决方案中,但似乎没有任何效果。

Edited : 编辑:

This is my full gradle file 这是我完整的gradle文件

apply plugin: 'com.android.application'


repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    //compile 'com.android.support:cardview-v7:21.+'
    compile('com.google.http-client:google-http-client-android:1.18.0-rc') {
        exclude(group: 'com.google.android', module: 'android')
        exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
    }
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile project(path: ':backend', configuration: 'android-endpoints')
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile project(':library')
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile 'com.android.support:support-v4:19.+'
    compile 'com.google.android.gms:play-services:4.4.52'
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile 'com.android.support:support-v13:19.+'
    compile 'com.google.code.gson:gson:2.+'
    compile 'com.github.castorflex.smoothprogressbar:library:0.5.2'
}

android {
    signingConfigs {
        ...
    }
    compileSdkVersion 19
    buildToolsVersion '20.0.0'
    defaultConfig {
        applicationId ...
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName '1.0'
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
    }
    dexOptions {
        preDexLibraries = false
    }
    productFlavors {
    }
}

Works for me. 为我工作。 You should post more of your build.gradle script (in particular, how exactly you tried to put mavenCentral() in the script), but the gist is that you need the following outside of the android {} block in the script (and this is in addition to the similar code in the buildscript {} block): 您应该发布更多build.gradle脚本(特别是尝试将mavenCentral()放入脚本中的方式),但是要点是您需要在脚本中的android {}块之外添加以下内容(并且除了buildscript {}块中的类似代码之外):

buildscript {
    // ...
}

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.github.castorflex.smoothprogressbar:library:0.5.2'
}

android {
    // ...
}

Then re-sync your project with Gradle. 然后与Gradle重新同步您的项目。

使用此方法:

compile 'com.github.castorflex.smoothprogressbar:library:0.5.2@aar'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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