服务器接入aar文件,gradle 上传aar包到私有服务器 && 访问上传的包

参考文章

lib包gradle修改

plugins {

id 'com.android.library'

}

apply plugin: 'maven'

//上传到Maven仓库的task

uploadArchives{

repositories{

mavenDeployer{

repository(url: "http://xxxx:端口号/repository/仓库名称/") {//

authentication(userName: "填写账户", password: "填写密码")//设置用户名密码

}

pom.groupId = "com.xxx.httpdemo"

pom.artifactId = "androidlib"

pom.version = "1.0.0"

//最后引入的效果是这样的

//implementation 'com.xxx.httpdemo.androidlib:1.0.0@aar'

pom.project {

licenses {

license {

name 'The Apache Software License, Version 2.0'

url 'http://www.apache.org/licenses/LICENSE-2.0.txt'

}

}

}

}

}

}

android {

.....

}

上传aar

9f74a75597e8

上传方式.jpg

重要!上传包,是需要赋予上传权限的

赋予仓库权限

xxxxx-maven2-maven-release-add

xxxxx-maven2-maven-release-edit

赋予用户权限

maven-release.deploy

访问上传的包

根gradle修改

allprojects {

repositories {

jcenter()

maven{

//私有maven仓库路径

url '域名:端口/repository/仓库名/'

credentials{//设置账户密码

username '填写账户'

password '填写密码'

}

}

}

}

单独上传aar或jar包

注意,有可能你当前登录的账号权限不够,你可以拿admin的超级权限去上传

9f74a75597e8

单独上传aar_jar_0.jpg

9f74a75597e8

1618885689(1).jpg

上传成功后,记得使用 com.gxx.payutils.libs:sande:3.0.0@aar 这种格式的

上传遇到错误信息

Warning: there were 1 classes in incorrectly named files.

You should make sure all file names correspond to their class names.

The directory hierarchies must correspond to the package hierarchies.

(http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)

If you don't mind the mentioned classes not being written out,

you could try your luck using the '-ignorewarnings' option.

解决办法就是将混淆关闭

nexus 405 http method put is not supported by this url

你填写的url地址错误

手动上传的aar/jar包到私有仓库,导致aar/jar文件不可以下载。从错误的信息上来看,是pom文件访问不了

- http://nexus.gxx.cn/repository/maven-releases/com/xx/push/libs/huawei/1.0.0/huawei-1.0.0.pom

- https://dl.google.com/dl/android/maven2/com/wjxls/push/libs/huawei/1.0.0/huawei-1.0.0.pom

- https://jcenter.bintray.com/com/wjxls/push/libs/huawei/1.0.0/huawei-1.0.0.pom

9f74a75597e8

1609330465.jpg

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要发布本地 AAR ,您需要完成以下步骤: 1. 在您的项目根目录中的 `build.gradle` 文件中添加 Maven 插件: ``` plugins { id 'maven-publish' } ``` 2. 配置发布信息。在 `build.gradle` 文件中添加以下内容: ``` group = 'com.example' // 填写您想要发布的的 Group ID version = '1.0.0' // 填写您想要发布的的版本号 publishing { publications { MyPublication(MavenPublication) { artifact file('path/to/your/aar/file') // 填写您想要发布的 AAR 的路径 groupId group version version artifactId 'your-library-name' // 填写您想要发布的的 Artifact ID pom.withXml { // 填写您想要发布的的信息 def dependenciesNode = asNode().appendNode('dependencies') def dependencyNode = dependenciesNode.appendNode('dependency') dependencyNode.appendNode('groupId', 'com.example') dependencyNode.appendNode('artifactId', 'example-library') dependencyNode.appendNode('version', '1.0.0') } } } repositories { mavenLocal() //配置本地 maven 仓库 } } ``` 注意:在 `pom.withXml` 中,您需要填写您想要发布的的信息,例如依赖项等。 3. 运行 `./gradlew publish` 命令,Gradle 将会发布您的 AAR 到本地 Maven 仓库中。如果您需要发布到其他 Maven 仓库,请将 `mavenLocal()` 替换为其他 Maven 仓库 URL。 4. 如果您的 AAR 依赖其他库,您需要将这些库发布到本地仓库或其他 Maven 仓库中,否则其他开发者在使用您的 AAR 时会出现依赖错误。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值