美文网首页
Library 发布到 Bintray Jcenter

Library 发布到 Bintray Jcenter

作者: simplehych | 来源:发表于2019-01-23 19:06 被阅读0次

    仓库查询地址:
    https://jcenter.bintray.com

    Step1 注册bintray

    官网地址:https://bintray.com
    个人用户请点击右侧红框位置,注意不要盲目注册首页醒目的绿色 START YOUR FREE TRIAL,选择右侧暗淡无光的,否则之后会遇到找不到404,找不到repo等问题

    注册 Bintray

    Step2 项目 build.gradle 配置

    工程下的 build.gradle 文件添加如下如下配置

    repositories {
            // 注意修改 google() jcenter()为如下代码
            maven {
                url "https://maven.google.com"
            }
            jcenter {
                url "http://jcenter.bintray.com/"
            }
        }
        dependencies {
            // 添加bintray
            classpath 'com.novoda:bintray-release:0.9'
    }
    

    Step3 Libraray 的 build.gradle 配置

    在Libraray Module的 build.gradle 下添加如下代码

    apply plugin: 'com.novoda.bintray-release'
    publish {
        //bintray机构名,在网站建立的机构
        userOrg = 'simple'
        //bintray的repo名称,在网站建立的仓库
        repoName = 'happy'
        //com.机构名.repo名称
        groupId = 'com.simple.happy'
        //项目名称
        artifactId = 'library'
        //版本号
        publishVersion = '1.0.0'
        desc = 'simple, happy'
        // 站点地,注意写 github 的项目地址,否则后期可能导致 VCS 错误
        website = 'https://github.com/simplehych/HappilyEverAfter'
    }
    

    Step4 命令上传到 Jcenter

    ./gradlew clean build bintrayUpload -PbintrayUser=你的用户名 -PbintrayKey=账户的Key值 -PdryRun=false  --stacktrace
    

    如下如查看账户的 Key值

    账户的KEY值

    注意需要 java1.8环境,检测javac -version,之前 Drozer 编译安装需要1.7环境

    Step5 Add to Jcenter

    bintray上找到repo点击 Add to Jcenter,等待审核
    如图右下角,注意 VCS 是在 Website 基础上添加.git,要确保该地址可以访问


    旧版 Add to Jcenter 新版 Add to Jcenter

    Step6使用

    类似

    implementation 'com.android.support:appcompat-v7:28.0.0'
    

    注意需要审核通过后才可以使用,请耐心等待,有消息通知


    使用

    Q & A

    Q1

    * What went wrong:
    A problem occurred configuring root project 'FirstBintraySample'.
    > Could not resolve all artifacts for configuration ':classpath'.
       > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11.
         Required by:
             project :
    

    A1
    https://stackoverflow.com/questions/25994163/could-not-resolve-all-dependencies-for-configuration-classpath

    google()
    jcenter()
    

    修改为->

    maven {
        url "https://maven.google.com"
    }
    jcenter {
        url "http://jcenter.bintray.com/"
    }
    

    Q2:

    ava.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
    

    A2:
    https://stackoverflow.com/questions/40927360/java-lang-unsupportedclassversionerror-com-android-build-gradle-appplugin-uns
    需要 java1.8环境

    Q3:

    * What went wrong:
    Execution failed for task ':peopleinteract:mockableAndroidJar'.
    > java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.builder.utils.FileCache$FileCreatorException: java.lang.NullPointerException
    

    A3:
    方法一:

    1. Go to File -> Settings -> Build, Execution, Deployment -> Compiler
    2. Add to "Command-line Options": -x :app:mockableAndroidJar
    3. Press "OK" and try to Rebuild Project again.

    方法二:

    allprojects {
        repositories {
            jcenter()
        }
            /**防止调用过时的mockableAndroidJar报错**/
        gradle.taskGraph.whenReady {
            tasks.each { task ->
                if (task.name.equals('mockableAndroidJar')) {
                    task.enabled = false
                }
            }
        }
    }
    

    相关文章

      网友评论

          本文标题:Library 发布到 Bintray Jcenter

          本文链接:https://www.haomeiwen.com/subject/jbdsjqtx.html