放弃JitPack,发布Android Library
放弃JitPack 不能及时编译出错误来导致每次需要在GitHub release 提交 release 还不支持23以上
发布Android Library注意点:
第一步:注册帐号
注册帐号地址:
https://bintray.com/signup/oss,https://bintray.com/signup/oss,https://bintray.com/signup/oss
第二步 Android工程配置
在project build.gradle
添加
还有lib build.gradle
添加
app 不用配置
// 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.0.1' classpath 'com.novoda:bintray-release:0.5.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' // Add this line } } allprojects { repositories { google() jcenter() maven { url 'https://dl.bintray.com/linlsyf/maven' } } } task clean(type: Delete) { delete rootProject.buildDir }
https://dl.bintray.com/linlsyf/maven' 为个人地址
lib 库配置
apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.novoda.bintray-release' android { compileSdkVersion 26 lintOptions { abortOnError false } defaultConfig { minSdkVersion 15 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { debug { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } tasks.withType(JavaCompile){ options.encoding = "UTF-8"} publish { userOrg = 'linlsyf' // bintray注册的用户名 groupId = 'com.easysoft.widget.lib' // 包名 artifactId = 'easywidget'// bintray创建的package publishVersion = '1.0.0' } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:23.2.1' 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 部分为个人设置
第三步 发布
1 gradlew assembleRelease 才能生成 release
2 gradlew bintrayUpload 检查是否有错误并解决 如编码错误需要去除掉中文注释
3 因为lib 有自己配置信息
4 提交
gradlew aR bintrayUpload -PbintrayUser=linlsyf -PbintrayKey=linlsyf -PdryRun=false -x releaseAndroidJavadocs |
linlsyf 为自己的名字 第二个配置自己的 apikey 替换即可 |
4 添加到jcenter
5易错点
如果出现
Execution failed for task ':lib:bintrayUpload'.
> java.net.SocketException: Connection reset by peer: socket write error
大概是你不适合开发吧