Android Studio发布aar到Jcenter,插件找不到

参考:

https://www.jianshu.com/p/5be222e98efc?from=jiantop.com // gradle使用

https://github.com/nuuneoi/JCenter/blob/master/installv1.gradle // 依赖gradle位置

 

目标:

    之前实现了Android Studio发布aar到Jcenter,具体可参考:https://blog.csdn.net/u014803950/article/details/64124375

    然而,经常遇到一个问题:即Android Studio经常找不到插件,问题出现在一下两行

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

    本文主要目标在于解决这个问题。

 

分析:

    1,问题出现的原因在于:依赖的远程库无法下载(可能是网络问题,也可能是服务器不稳定,也可能是墙)

    2,解决思路:将远程库编译成本地

 

解决步骤:

   1,找到远程文件:https://github.com/nuuneoi/JCenter/blob/master/installv1.gradle

   2,将远程文件,在本地实现 

   3,gradle修改依赖远程,改为,依赖本地

 

1,找到远程文件

    直接打开github上,查找即可

2,将远程文件,在本地实现

2-1,目录如下图所示

2-2,文件内容(其实照搬github上,有一个字段更改[因为gradle不能自动识别大小写]) 

#bintrayv1.gradle

apply plugin: 'com.jfrog.bintray'
version = libraryVersion
if (project.hasProperty("android")) { // Android libraries
    task sourcesJar(type: Jar) {
        classifier = 'sources'
        from android.sourceSets.main.java.srcDirs
    }
    task javadoc(type: Javadoc) {
        source = android.sourceSets.main.java.srcDirs
        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    }
} else { // Java libraries
    task sourcesJar(type: Jar, dependsOn: classes) {
        classifier = 'sources'
        from sourceSets.main.allSource
    }
}
task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}
artifacts {
    archives javadocJar
    archives sourcesJar
}
// Bintray
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    configurations = ['archives']
    pkg {
        repo = bintrayRepo
        name = bintrayName
        desc = libraryDescription
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = allLicenses
        publish = true
        publicDownloadNumbers = true
        version {
            desc = libraryDescription
            gpg {
                sign = true //Determines whether to GPG sign the files. The default is false
                passphrase = properties.getProperty("bintray.gpg.password")
                //Optional. The passphrase for GPG signing'
            }
        }
    }
}

#installv1.gradle

apply plugin: 'com.github.dcendents.android-maven'
group = publishedGroupId                               // Maven Group ID for the artifact
install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'
                groupId publishedGroupId
                artifactId artifact // 修改了大小写
                // Add your description here
                name libraryName
                description libraryDescription
                url siteUrl
                // Set your license
                licenses {
                    license {
                        name licenseName
                        url licenseUrl
                    }
                }
                developers {
                    developer {
                        id developerId
                        name developerName
                        email developerEmail
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl
                }
            }
        }
    }
}

3,gradle修改依赖远程,改为,依赖本地

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

    以上便全部完成,接下来编译、使用命令行上传aar即可,再也不用担心找不到远程文件了

 

 

 

 

 

 

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值