这是我第一次做远程仓库。但是我在访问它时遇到了一些问题。以下是我的 gradle 文件:
根gradle文件
// Top-level build file where you can add configuration options
common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle 文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.imagelettericon"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.github.akashandroid90:imageletter:1.0'
}
每次同步代码时我都会遇到同样的错误
Failed to resolve:
com.github.akashandroid90:imageletter:1.0
我已经关注this和 this链接以制作我的 repo 协议(protocol)。但是现在我无法在 gradle 文件中访问它。
最佳答案
你必须改变你的依赖。
compile 'com.github.akashandroid90:imageletter:1.0'
是错误的。
阅读您应该使用的 github 存储库中的文档。
dependencies {
compile 'com.imageletter:ImageLetterIcon:1.0'
}
但是您可以在 jcenter repo 中检查依赖关系.
看了repo中的pom文件,我对这个名字有些疑惑。
应该是:
compile 'com.github.akashandroid90:image-letter-icon:1.0'
您可以使用另一种方式添加对 github 项目的依赖,使用 github 存储库和 jitpack plugin
在这种情况下,您必须将此 repo 添加到您的 build.gradle
repositories {
// ...
maven { url "https://jitpack.io" }
}
和依赖:
dependencies {
compile 'com.github.User:Repo:Tag'
}
你的情况是
compile 'com.github.akashandroid90:ImageLetterIcon:1.0'
更多信息 here .
关于android - 访问远程 gradle 依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33405012/