As for the difference between jcenter and maven, I will not introduce it. The advantage is to improve development efficiency, save time and trouble, and there is no need to import moudle, com aar***. First of all, you need to register your own account on the Bintray jcenter official website, or log in with your github account. If the mailbox bound to github is a mobile phone mailbox, you cannot log in, so it is best to apply for a gmail mailbox when you register for jcenter. At the end put a vpn apk that can overturn the wall. Go google to get started.
After the above 123 steps, save the key for a while
After the above steps, after the library is created, write a little code for testing, and then configure the binary-release plugin to be uploaded in the root build.gradle and the library's build.gradle
As shown in the figure:
Code in the picture: library build.gradle
apply plugin: 'com.android.library' apply plugin: 'com.novoda.bintray-release' publish { userOrg = 'liuguodong' //bintray.com username groupId = 'com.liuguodong' //path on jcenter artifactId = 'LgdMyUtilsx' //project name publishVersion = '1.0.0' //version number desc = 'https: //github.com/printlybyte' //description, not important website = 'https://github.com/printlybyte' //website, preferably there, not important } android { compileSdkVersion 26 buildToolsVersion '27.0.1' defaultConfig { minSdkVersion 15 targetSdkVersion 19 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test. espresso:espresso-core:3.0.1' } //resolve wrong GBK unmappable encoding allprojects { tasks.withType(Javadoc) { options{ encoding "UTF-8" charSet 'UTF-8' links "http://docs.oracle.com/javase/7/docs/api" } } }
根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.0.0' classpath 'com.novoda:bintray-release:0.5.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 }
接下来按下Alt+F12打开Terminal(路径默认是当前工程下)输入
gradlew clean build bintrayUpload -PbintrayUser=liuguodong -PbintrayKey=******************************* -PdryRun=false
其中PbintrayUser 是你的bintray账户名字 key为刚才保存的那个key ,然后回车 如果出现错误看末尾
到此完成上传:
引用:
到此完成上传,可能会出现的问题:
(1)如图
解决方法:在要上传的gradle 文件的android节点里面添加以下代码:
lintOptions {
abortOnError false
}
- 1
- 2
- 3
(2)如图
出现Could not create package是因为插件创建不了库。
解决方法:我们手动创建一个
(3)有可能出现乱码问题
解决问题:在项目根目录gradle文件中添加以下代码
allprojects {
tasks.withType(Javadoc) {
options{
encoding "UTF-8"
charSet 'UTF-8'
links "http://docs.oracle.com/javase/7/docs/api"
}
}
}
vpn:http://download.csdn.net/download/liu3364575/10221239,不想下载的在下面评论留下邮箱