android - 访问远程 gradle 依赖

标签 android git maven android-gradle-plugin build.gradle

这是我第一次做远程仓库。但是我在访问它时遇到了一些问题。以下是我的 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

我已经关注thisthis链接以制作我的 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/

相关文章:

android - 尝试使用 Window.FEATURE_CUSTOM_TITLE 但得到 Exception :You cannot combine custom titles with other title feature. 。

android - NDK 主文件夹中的目录与 NDK 版本有何关系?

java - GWT CodeServer使用maven和新包装gwt-app和gwt-lib的增量编译问题

git - 为什么更改相邻行但独立修改会导致 git merge 冲突?

git - Visual Studio Code : Git diff over git gutter indicator

java - Hadoop 构建在 Windows 中失败 : zconf. native.sln 中缺少 h?

java - 不可解析的父 POM : Could not find artifact

java - income_amount (code 1) : , 编译时:SELECT SUM(income_amount) FROM INCOME WHERE month = '24'

android - Espresso 测试失败 : AssertionFailedWithCause: Wanted to match 1 intents. 实际上匹配 0 个 Intent

git - 如何从分支创建 Meteor 应用程序