Issue resolving gradle dependency in android studi

2019-04-23 05:51发布

问题:

I am trying to add a styled progress bar from https://android-arsenal.com/details/1/1375

There it says:

Add the specific repository to your build file:

repositories {
   maven {
      url "https://jitpack.io"
   }
}

Add the dependency in your build file (do not forget to specify the correct qualifier, usually 'aar'):

dependencies {
   compile 'com.github.akexorcist:Android-RoundCornerProgressBar:1.0.0'
}

Well I did that... build.gradle (Project)

buildscript {
repositories {
    jcenter()
    maven {
      url "https://jitpack.io"
   }

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

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

allprojects {
  repositories {
    jcenter()
  }
}

build.gradle (Module): apply plugin: 'com.android.application'

android { compileSdkVersion 21 buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.example.chaz.simsirl"
    minSdkVersion 15
    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.github.akexorcist:Android-RoundCornerProgressBar:1.0.0'
}

Then in messages it says: Error:A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'. Could not find com.akexorcist:Android-RoundCornerProgressBar:1.0.0. Searched in the following locations: https://jcenter.bintray.com/com/akexorcist/Android-RoundCornerProgressBar/1.0.0/Android-RoundCornerProgressBar-1.0.0.pom https://jcenter.bintray.com/com/akexorcist/Android-RoundCornerProgressBar/1.0.0/Android-RoundCornerProgressBar-1.0.0.jar file:/C:/Users/pc/AppData/Local/Android/sdk/extras/android/m2repository/com/akexorcist/Android-RoundCornerProgressBar/1.0.0/Android-RoundCornerProgressBar-1.0.0.pom file:/C:/Users/pc/AppData/Local/Android/sdk/extras/android/m2repository/com/akexorcist/Android-RoundCornerProgressBar/1.0.0/Android-RoundCornerProgressBar-1.0.0.jar file:/C:/Users/pc/AppData/Local/Android/sdk/extras/google/m2repository/com/akexorcist/Android-RoundCornerProgressBar/1.0.0/Android-RoundCornerProgressBar-1.0.0.pom file:/C:/Users/pc/AppData/Local/Android/sdk/extras/google/m2repository/com/akexorcist/Android-RoundCornerProgressBar/1.0.0/Android-RoundCornerProgressBar-1.0.0.jar Required by: SimsIRL:app:unspecified

回答1:

Try to replace your dependency with this:

compile 'com.akexorcist:RoundCornerProgressBar:1.0.0' 

This package is available in jCenter.

Then you can remove this:

maven {
   url "https://jitpack.io"
}

Reference: https://github.com/akexorcist/Android-RoundCornerProgressBar#download



回答2:

You would need to add the jitpack repository in a different place:

allprojects {
  repositories {
    jcenter()
    maven { url "https://jitpack.io" }
  }
}

Then it works

In your first snippet it was added under buildscript and it should be removed from there.