目录1、创建 Android 库 2、上传aar包至Maven私服 3、其他项目使用 4、QA 1、创建 Android 库 按以下步骤在项目中创建新的库模块: 依次点击 F
按以下步骤在项目中创建新的库模块:
打开新模块 build.gradle 文件,按如下说明修改:
plugins {
id 'com.android.library' // 库模块
id 'Kotlin-android'
id 'maven' // 引入maven plugin
}
def snapshotVersionCode = 101
def snapshotVersion = "1.0.1"
dependencies {
// 友盟基础组件库(所有友盟业务SDK都依赖基础组件库)
implementation "com.umeng.umsdk:common:9.3.6"
implementation "com.umeng.umsdk:asms:1.2.0"
implementation "com.umeng.umsdk:apm:1.1.1"
}
uploadArcHives {
configuration = configurations.archives
repositories {
mavenDeployer {
repository(url: 'Http://nexus.xxxxx.com/repository/maven-snapshots') {
authentication(userName: 'userNameXXXX', passWord: 'passwordXXXXX')
}
pom.project {
version snapshotVersion + '-SNAPSHOT'
artifactId 'lib-umeng'
groupId 'com.xxxxx'
packaging 'aar'
description 'lib-umeng Initial submission'
}
}
}
}
上传aar 到maven
选择右侧Gradle > Module Name > upload ,双击uploadArchives运行
Project build.gradle添加 maven
allprojects {
repositories {
maven { url 'https://dl.bintray.com/umsdk/release' } // umeng.umsdk相关maven
maven { url 'https://nexus.xxxxx.com/repository/maven-snapshots' } // 刚刚aar上传的maven
}
}
Module 中引用,build.gradle添加如下引用
dependencies {
api ('com.xxxxx:lib-umeng:1.0.1-SNAPSHOT@aar') { // 刚刚生成的aar
implementation "com.umeng.umsdk:common:9.3.6" // 注意,aar implementation的依赖需要重新引用
implementation "com.umeng.umsdk:asms:1.2.0"
implementation "com.umeng.umsdk:apm:1.1.1"
}
}
maven上传报错:
Execution failed for task ':lib-umeng:uploadArchives'.
\> Could not publish configuration 'archives'
\> Failed to deploy artifacts: Could not transfer artifact com.xxxxx:lib-umeng:aar:1.0.1 from/to remote (http://nexus.xxxxx.asia/repository/maven-snapshots): Failed to transfer file: http://nexus.xxxxx.asia/repository/maven-snapshots/com/xxxxx/lib-umeng/1.0.1/lib-umeng-1.0.1.aar. Return code is: 400, ReasonPhrase: Repository version policy: SNAPSHOT does not allow version: 1.0.1.
解决:version snapshotVersion + '-SNAPSHOT' 标记:-SNAPSHOT
参考:developer.android.com/studio/proj…
以上就是Android打包上传AAR文件到Maven仓库的示例的详细内容,更多关于Android打包上传文件到Maven仓库的资料请关注编程网其它相关文章!
--结束END--
本文标题: Android打包上传AAR文件到Maven仓库的示例
本文链接: https://www.lsjlt.com/news/122132.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-21
2023-10-28
2023-10-28
2023-10-27
2023-10-27
2023-10-27
2023-10-27
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0