【问题标题】:Try to add library to gradle尝试将库添加到 gradle
【发布时间】:2016-04-24 09:42:18
【问题描述】:

我编写了一个库并尝试在项目中设置一个 gradle 依赖项。从这个网站上的一个教训:http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en
一切顺利,在网站上注册,创建存储库,创建并保存密钥。但是当他移动到项目中的文件时却出错了。
以下是截图:
版本自己通过网站创建
我的项目 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'

我的应用模块 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 时我的错误:

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

更新
我没有你(Fondesa)在左下划线

【问题讨论】:

    标签: android git maven android-gradle-plugin


    【解决方案1】:

    你做的过程是正确的,你还可以做两件事,我发个截图来解释一下:

    1. 检查您的依赖项是否链接到jCenter,您可以在项目常规设置的右下角找到该按钮

    2. 检查您在 build.gradle 文件中的依赖声明 diplom.itis.animationlib:animlib:0.9.0 是否与我在屏幕截图左下角带下划线的声明相匹配。

    【讨论】:

    • 我更新了我的问题,我在我的包裹中找不到您在左下角划线的内容
    • @metalink 在 Bintray 上打开你的 0.9.0 库并进入“文件”选项卡,导航到文件夹,你能找到扩展名为“.pom”的文件吗?
    猜你喜欢
    • 1970-01-01
    • 2016-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-12
    • 2014-08-29
    • 2014-10-26
    • 1970-01-01
    相关资源
    最近更新 更多