Android打包上傳AAR文件到Maven倉庫的示例
1、創(chuàng)建 Android 庫
按以下步驟在項目中創(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 = 101 def 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運行
3、其他項目使用
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)注腳本之家其它相關(guān)文章!
- Android將項目導出為Library并在項目中使用教程
- Android Studio多工程引用同一個library項目配置的解決方法
- android studio library 模塊中正確引用aar的實例講解
- Android Data Binding 在 library module 中遇到錯誤及解決辦法
- Android Support Library 標題欄(Toolbar)滾動效果實現(xiàn)方法
- Android 詳解Studio引用Library與導入jar
- android底部彈出iOS7風格對話選項框(QQ對話框)--第三方開源之IOS_Dialog_Library
- 解析ADT-20問題 android support library
- Android?使用maven?publish插件發(fā)布產(chǎn)物(aar)流程實踐
- 發(fā)布?Android?library?到?Maven?解析
相關(guān)文章
詳解Android使GridView橫向水平滾動的實現(xiàn)方式
Android為我們提供了豎直方向的滾動控件GridView,這篇文章主要介紹了Android使GridView橫向水平滾動的實現(xiàn)方式,有興趣的可以了解一下2017-05-05Flutter Navigator路由傳參的實現(xiàn)
本文主要介紹了Flutter Navigator路由傳參的實現(xiàn),文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-04-04Kotlin?LinearLayout與RelativeLayout布局使用詳解
Kotlin?的基本特性就先寫到這里,我們這個系列的定位是基礎(chǔ),也就是能用就好,夠用就好,我們不會舉太多的例子,但是這些都是最經(jīng)常用到的特性。從這節(jié)開始就是Kotlin和android?進行結(jié)合,使用Kotlin進行安卓應用的開發(fā)了2022-12-12Android自定義view實現(xiàn)動態(tài)柱狀圖
這篇文章主要為大家詳細介紹了Android自定義view實現(xiàn)動態(tài)柱狀圖的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-08-08Android UI設(shè)計與開發(fā)之使用ViewPager實現(xiàn)歡迎引導頁面
這篇文章主要為大家詳細介紹了Android UI設(shè)計與開發(fā)之使用ViewPager實現(xiàn)歡迎引導頁面,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-08-08Android開發(fā)使用Handler實現(xiàn)圖片輪播功能示例
這篇文章主要介紹了Android開發(fā)使用Handler實現(xiàn)圖片輪播功能,涉及Android基于Handler操作圖片的相關(guān)實現(xiàn)技巧與操作注意事項,需要的朋友可以參考下2017-09-09