Android打包上傳AAR文件到Maven倉庫的示例
按以下步驟在項目中創(chuàng)建新的庫模塊:
依次點擊 File > New > New Module。 在隨即顯示的 Create New Module 窗口中,依次點擊 Android Library 和 Next。 為您的庫命名,并為庫中的代碼選擇一個最低 SDK 版本,然后點擊 Finish。 2、上傳aar包至Maven私服打開新模塊 build.gradle 文件,按如下說明修改:
plugins { id ’com.android.library’ // 庫模塊 id ’kotlin-android’ id ’maven’// 引入maven plugin}def snapshotVersionCode = 101def snapshotVersion = '1.0.1'/* 此處省略 android{} 相關(guān)配置 */dependencies { // 友盟基礎(chǔ)組件庫(所有友盟業(yè)務(wù)SDK都依賴基礎(chǔ)組件庫) implementation 'com.umeng.umsdk:common:9.3.6' implementation 'com.umeng.umsdk:asms:1.2.0' implementation 'com.umeng.umsdk:apm:1.1.1'}/*快照版 maven上傳*/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選擇右側(cè)Gradle > Module Name > upload ,雙擊uploadArchives運行
Project build.gradle添加 maven
allprojects { repositories {/* 此處省略了其他配置 */ maven { url ’https://dl.bintray.com/umsdk/release’ } // umeng.umsdk相關(guān)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' }}4、QA
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倉庫的示例的詳細內(nèi)容,更多關(guān)于Android打包上傳文件到Maven倉庫的資料請關(guān)注好吧啦網(wǎng)其它相關(guān)文章!
相關(guān)文章:
1. python爬蟲實戰(zhàn)之制作屬于自己的一個IP代理模塊2. python實現(xiàn)讀取類別頻數(shù)數(shù)據(jù)畫水平條形圖案例3. 如何理解PHP核心特性命名空間4. python 利用toapi庫自動生成api5. Android Studio設(shè)置顏色拾色器工具Color Picker教程6. python操作數(shù)據(jù)庫獲取結(jié)果之fetchone和fetchall的區(qū)別說明7. python中PyQuery庫用法分享8. Springboot設(shè)置默認訪問路徑方法實現(xiàn)9. 小技巧處理div內(nèi)容溢出10. Android Studio 2.0 功能介紹
