Android Studio安装上传Bintray插件和填写相关信息:(下面选用我测试通过并且操作路径最短的方式)
这是根build源文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.3' classpath 'com.novoda:bintray-release:+' // 新增 // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } tasks.withType(Javadoc) { // 新增 options.addStringOption('Xdoclint:none', '-quiet') options.addStringOption('encoding', 'UTF-8') } } task clean(type: Delete) { delete rootProject.buildDir }
这是lib的源build文件:
`apply plugin: ``'com.android.library'` `apply plugin: ``'com.novoda.bintray-release'` `// 新增` `android {` `compileSdkVersion ``28` `defaultConfig {` `minSdkVersion ``15` `targetSdkVersion ``28` `versionCode ``2` `versionName ``"1.0.2"` `testInstrumentationRunner ``"android.support.test.runner.AndroidJUnitRunner"` `}` `buildTypes {` `release {` `minifyEnabled ``false` `proguardFiles getDefaultProguardFile(``'proguard-android.txt'``), ``'proguard-rules.pro'` `}` `}` `lintOptions { ``// 新增` `abortOnError ``false` `}` `}` `dependencies {` `implementation fileTree(dir: ``'libs'``, include: [``'*.jar'``])` `implementation ``'com.android.support:appcompat-v7:28.0.0-rc02'` `testImplementation ``'junit:junit:4.12'` `androidTestImplementation ``'com.android.support.test:runner:1.0.2'` `androidTestImplementation ``'com.android.support.test.espresso:espresso-core:3.0.2'` `}` `publish { ``// 新增` `userOrg = ``'huangweicai'` `// 注册bintray时的username` `groupId = ``'com.infinitus_demo_lib'` `// 项目包名` `artifactId = ``'infinitus_demo_lib'` `// 项目名` `publishVersion = ``'1.0.2'` `// 发布版本号` `desc = ``'Summarize the tools or methods commonly used in routine development'` `// 项目描述,可选项` `website = ``'[https://github.com/huangweicai/infinitus_demo_lib'](https://github.com/huangweicai/infinitus_demo_lib')` `// 项目站点,可选项` `}`
gradlew generatePomFileForReleasePublication gradlew publishReleasePublicationToMavenLocal gradlew bintrayUpload -PbintrayUser=xxx -PbintrayKey=xxx -PdryRun=false
其中,PbintrayUser是Bintray的用户名,PbintrayKey是Bintray的API Key。(API Key在注册成功后,可以在修改信息的界面找到,最好在第一次注册成功后就记录好)
等待执行,看到BUILD SUCCESSFUL说明上传Bintray成功。
以上就是Android Studio打包上传到Jcenter的完整流程。