尝试将库添加到gradle

时间:2016-04-24 09:42:18

标签: android git maven android-gradle

我写了一个库并尝试在项目中设置gradle依赖项。根据本网站的课程制作:http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en
一切顺利,在网站上注册,创建存储库,创建和保存密钥。但当他转移到项目中的档案时都出现了错误 以下是截图: My repo on Bintray
版本通过网站创建了自己 我的项目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.5.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
// Plugin used to upload authenticated files to BinTray through Gradle
plugins {
    id "com.jfrog.bintray" version "1.5"
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我的图书馆gradle文件:

apply plugin: 'com.android.library'

ext {
    bintrayRepo = 'maven'
    bintrayName = 'AnimLib'
    publishedGroupId = 'diplom.itis.animationlib'
    libraryName = 'animlib'
    artifact = 'animlib'
    libraryDescription = ''
    siteUrl = 'https://github.com/metalink94/AnimationLib'
    gitUrl = 'https://github.com/metalink94/AnimationLib.git'
    libraryVersion = '0.9.0'
    developerId = 'metalink94'
    developerName = 'Denis'
    developerEmail = 'denisnovikov94@gmail.com'
    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ["Apache-2.0"]
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        group = 'diplom.itis.animationlib' // Change this to match your package name
        version = '0.9.0' // Change this to match your version number

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.0'
    apply plugin: 'com.jfrog.bintray'
    apply plugin: 'com.github.dcendents.android-maven'
    apply plugin: 'com.android.library'

}
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'

我的app模块gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "diplom.itis.animationlib"
        minSdkVersion 14
        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')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.github.clans:fab:1.6.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.github.wangjiegulu:AndroidInject:1.0.6'
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.alexvasilkov:android-commons:1.2.4'
    compile 'diplom.itis.animationlib:animlib:0.9.0'
    //compile project(':animlib')
}

我尝试同步gradle时的错误: enter image description here

请有人帮助我,告诉我哪里出错了?

更新
我没有你(Fondesa)在左下角的下划线 enter image description here

1 个答案:

答案 0 :(得分:0)

你所做的过程是正确的,你还可以做两件事,我会发布截图来更好地解释它:

enter image description here

  1. 检查您的相关性是否与jCenter相关联,您可以在项目常规设置的右下角找到该按钮

  2. 检查diplom.itis.animationlib:animlib:0.9.0文件中的相关性声明build.gradle是否与屏幕截图左下角的下划线相符。