Android打包上傳AAR文件到Maven倉庫的示例
按以下步驟在項目中創建新的庫模塊:
依次點擊 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{} 相關配置 */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'}/*快照版 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選擇右側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' }}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倉庫的示例的詳細內容,更多關于Android打包上傳文件到Maven倉庫的資料請關注好吧啦網其它相關文章!
相關文章:
1. CentOS郵件服務器搭建系列—— POP / IMAP 服務器的構建( Dovecot )2. HTTP協議常用的請求頭和響應頭響應詳解說明(學習)3. IntelliJ IDEA創建web項目的方法4. Django使用HTTP協議向服務器傳參方式小結5. .NET 6實現滑動驗證碼的示例詳解6. 存儲于xml中需要的HTML轉義代碼7. Android studio 解決logcat無過濾工具欄的操作8. Django REST Swagger實現指定api參數9. ASP中實現字符部位類似.NET里String對象的PadLeft和PadRight函數10. django創建css文件夾的具體方法
