主要是跟着一位博主的这篇博客进行操作的:Android 上传自己的开源库到Bintray(超简单哦)
这里只记录一下中间遇到的问题:
在工程主目录下的build.gredle中添加备注编译不通过:
classpath 'com.novoda:bintray-release:0.4.0'
在网上找寻答案是,Android Studio3.14以及以上的版本需要将引入
classpath 'com.novoda:bintray-release:0.8.0'
这里在贴一下两个build.gradle的完整的代码:
主工程:
// 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:0.8.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Library:
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 11
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
allprojects {
repositories {
jcenter()
}
tasks.withType(Javadoc) {
options {
encoding "UTF-8"
charSet 'UTF-8'
links "http://docs.oracle.com/javase/7/docs/api"
}
}
}
publish {
repoName = 'xiangdada' //bintray仓库名
userOrg = 'xiangdada' //bintray注册的用户名
groupId = 'com.xiangdada' //compile引用时的第1部分groupId
artifactId = 'network' //compile引用时的第2部分项目名
publishVersion = '1.0.0' //compile引用时的第3部分版本号
desc = 'description'
website = '可写成github上面的代码地址路径'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
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'
api 'com.squareup.retrofit2:retrofit:2.5.0'
api 'io.reactivex.rxjava2:rxjava:2.2.4'
api 'io.reactivex.rxjava2:rxandroid:2.1.0'
api 'com.squareup.retrofit2:converter-gson:2.5.0'
api 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
api 'com.google.code.gson:gson:2.8.5'
api 'com.orhanobut:logger:2.2.0'
api 'com.squareup.okhttp3:logging-interceptor:3.14.0'
}