【问题标题】:My Android Studio Gradle is not getting the plugin from maven central我的 Android Studio Gradle 没有从 maven Central 获取插件
【发布时间】:2014-08-25 19:00:31
【问题描述】:

我尝试将smoothprogressbar 库添加到我的android 项目中

我将这些行添加到我的 build.gradle 中

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

当我同步 gradle 时,它​​会说 找不到:com.github.castorflex.smoothprogressbar:library:0.5.1

我尝试将 mavenCentral() 和 maven url 放入 build.gradle 和我在 stackoverflow 中找到的其他解决方案,但似乎没有任何效果。

已编辑:

这是我的完整 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 {
    }
}

【问题讨论】:

  • 您找到解决方案了吗?
  • 是的,实际上,当我们将其他一些存储库添加到存储库块中时,就会出现这个问题。我在 mavenCentral() 之前添加了 jcenter() 存储库,因此我无法加载外部 maven 依赖项。从存储库块中删除该 jcenter() 后,它开始工作。检查模块中的存储库块以及主项目 build.gradle

标签: android gradle android-gradle-plugin


【解决方案1】:

为我工作。您应该发布更多您的 build.gradle 脚本(特别是,您究竟如何尝试将 mavenCentral() 放入脚本中),但要点是您需要在脚本中的 android {} 块之外添加以下 (这是对 buildscript {} 块中类似代码的补充):

buildscript {
    // ...
}

repositories {
    mavenCentral()
}

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

android {
    // ...
}

然后将您的项目与 Gradle 重新同步。

【讨论】:

  • 我遵循了相同的结构,但仍然无法正常工作。我用完整的 build.gradle 代码更新了我的问题
【解决方案2】:

使用这种方法:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-29
    • 1970-01-01
    • 2022-06-16
    • 1970-01-01
    相关资源
    最近更新 更多