Advertisement

Android-sdk开发搭建与注意事项

阅读量:

注意事项:

1.资源名称不可与宿主一致防止冲突:

drawable,mipmap,layout,values

  1. 进行aars的打包处理时,默认情况下不会自动包含依赖项信息;建议采用maven构建工具生成aars包,并确保aars文件安全可靠地传输至目标位置

使用步骤:

1.修改app项目为lib项目

app切换为library

复制代码
 //apply plugin: 'com.android.application'

    
 apply plugin: 'com.android.library'

隐藏 defaultConfig下的applicationId

复制代码
    //        applicationId "com.example.xxxx"

AndroidManifest中修改:隐藏默认启动与桌面图标生成

复制代码
 <!--            <intent-filter>-->

    
 <!--                <action android:name="android.intent.action.MAIN" />-->
    
  
    
 <!--                <category android:name="android.intent.category.LAUNCHER" />-->
    
 <!--            </intent-filter>-->

2.通过maven将aar上传到本地或服务器

复制代码
 android{

    
 .....
    
 }
    
 uploadArchives {
    
     //maven上传到本地
    
     repositories {
    
     mavenDeployer {
    
         // 配置本地仓库路径,项目根目录下的repository目录中
    
         repository(url: uri('file://D://repository'))
    
         pom.groupId = "com.sdk.topup_sdk"// 唯一标识(通常为模块包名,也可以任意)
    
         pom.artifactId = "topup_sdk" // 项目名称(通常为类库模块名称,也可以任意)
    
         pom.version = "1.0.0" // 版本号
    
     }
    
     }
    
  
    
     //maven上传到服务器
    
 //    repositories {
    
 //        mavenDeployer {
    
 //            // 配置本地仓库路径,项目根目录下的repository目录中
    
 //            repository(url: 'http://127.0.0.1:8081/repository/maven-releases/') {
    
 //                authentication(userName: 'admin', password: 'admin123')
    
 //            }
    
 //            pom.project {
    
 //                groupId = "com.sdk.topup_sdk"// 唯一标识(通常为模块包名,也可以任意)
    
 //                artifactId = "topup_sdk" // 项目名称(通常为类库模块名称,也可以任意)
    
 //                version = "1.0.0" // 版本号
    
 //                packaging 'aar' //填写aar
    
 //                description 'update version 1.1.0 add new method' //更新描述
    
 //            }
    
 //        }
    
 //    }
    
 }
    
 dependencies {
    
 .....
    
 }

通过此按钮可以直接打包上传文件到相应目录

打包上传后的结果

3.宿主引入方式

build.gradle中直接追加仓库地址

复制代码
 allprojects {

    
     repositories {
    
     //本地仓库
    
     maven{ url = 'file://D://repository' }
    
     //远程仓库
    
 //        maven{ url = 'http://127.0.0.1:8081/repository' }
    
     }
    
 }

全部评论 (0)

还没有任何评论哟~