Android studio 2.2.2使用bintray存储库将我的app模块作为库发布到jcenter
作者:互联网
在这里,我已经成功完成了qr代码扫描项目.我用于qrcodereaderview 1.0.0 v url存储库.这是我的依赖.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:1.0.0'
compile files('libs/ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar')
}
我的项目中只有一个app模块.我想将这个项目作为库(.AAR)上传到jcenter存储库.
我已尝试过一些jcenter上传步骤,我也从bintrayupload获得了成功的上传响应.
出于这个原因,我创建了Github登录并创建了项目URL.但是,我没有将我的项目代码上传到github.我只在build.gradle中给出了空项目URL.
但是,当我在bintray存储库中看到时.我的bintray maven存储库上没有代码更新/版本更改.
Android Studio Project转换为.aar(库)文件并在以下步骤中上传到jcenter存储库.
1).我已经更改了主应用程序模块build.gradle文件以进行三次更改.
更改了库插件,注释了应用程序ID并更改了清单文件启动器活动.
我的app模块build.gradle文件:
//apply plugin: 'com.android.application'
apply plugin: 'com.android.library'
ext {
bintrayRepo = 'maven' //mavenrepo
bintrayName = 'app'
publishedGroupId = 'com.test.testsdkproj16'
libraryName = 'TestsdkProj16'
artifact = 'app'
libraryDescription = 'A simple qr code library calling your project in Android'
siteUrl = 'https://github.com/vhkrishnanv/TestsdkProj16'
gitUrl = 'https://github.com/vhkrishnanv/TestsdkProj16.git'
githubRepository= 'vhkrishnanv/TestsdkProj16'
libraryVersion = '1.0.0'
developerId = 'vhk*********6'
developerName = 'harikrish'
developerEmail = 'vhkris******@gmail.com'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
//applicationId "com.test.testsdkproj16"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:1.0.0'
compile files('libs/ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar')
}
// Place it at the end of the file
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
我的清单文件:
<activity android:name=".MainActivitySDK_16">
<intent-filter>
<action android:name="com.test.testsdkproj16.MainActivitySDK_16" />
<!--comment when exporting AAR below two lines-->
<!--<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />-->
</intent-filter>
</activity>
gradle.properties文件:
bintray.user=vhk*********6
bintray.apikey=***1f************************98f51***
2).将我的工作室项目上传到bintray.com的后续步骤.我已经使用了三个命令.
-gradleW clean
BUILD SUCCESSFUL
-gradleW install
BUILD SUCCESSFUL
-gradleW bintrayupload
BUILD SUCCESSFUL
执行上述三个命令后,当我在我的bintray存储库中看到时,我的存储库中没有任何变化.
我的存储库的截图
我不确切知道缺少哪一步.任何人都可以帮助解决这个错误.
总的来说,我想将我的Studio2.2.2项目(转换为.aar库)发布到jcenter存储库,并且需要获取我的项目URL. (当我在依赖项中的其他新项目中尝试此URL时,在同步时获取错误,因为,代码/ .aar不在存储库中上载)
我有一个待定的最后步骤.一旦代码上传,需要在bintray repos中等待jcenter同步.然后,我才能将上面的url用于其他新项目.
compile 'com.test.testsdkproj16:app:1.0.0'
解决方法:
在您提出的问题中,您已将信用证保存在gradle.properties中的bintray帐户中:
bintray.user=vhk*********6
bintray.apikey=***1f************************98f51***
如果您从以下位置查看源文件:
https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle
您将看到以下行:
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
您已将信用证放在错误的文件中.它们应该在local.properties中
编辑
经过长时间的讨论,该项目最终发布给了bintray.这里的问题是用户正在发布到另一个组织项目.事实上,@ gba的回答是正确的.
但是,建议@harikrishnan将bintray.gradle和install.gradle下载到项目中并进行修改.以下是他们应该如何看待:
bintray.gradle
apply plugin: 'com.jfrog.bintray'
apply from: '../bintray.data.gradle'
version = libraryVersion
if (project.hasProperty("android")) { // Android libraries
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
task javadoc(type: Javadoc) {
options.addBooleanOption('Xdoclint:none', true)
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
} else { // Java libraries
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(new FileInputStream(file(rootProject.file('local.properties'))))
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = bintrayRepo
name = bintrayName
desc = libraryDescription
websiteUrl = siteUrl
vcsUrl = gitUrl
userOrg = userOrg
licenses = allLicenses
publish = true
publicDownloadNumbers = true
}
}
install.gradle
apply plugin: 'com.github.dcendents.android-maven'
apply from: '../bintray.data.gradle'
group = publishedGroupId
install {
repositories.mavenInstaller {
pom {
project {
packaging 'aar'
groupId publishedGroupId
artifactId artifact
name libraryName
description libraryDescription
url siteUrl
licenses {
license {
name licenseName
url licenseUrl
}
}
developers {
developer {
id developerId
name developerName
email developerEmail
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
bintray.data.gradle:
ext {
bintrayRepo = 'maven'
bintrayName = 'samplename'
publishedGroupId = 'sample.package.name'
libraryName = 'SampleName'
artifact = 'samplename'
libraryDescription = ''
siteUrl = ''
gitUrl = ''
libraryVersion = '1.0.0'
developerId = ''
developerName = 'Zagórski'
developerEmail = ''
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
app的build.gradle:
apply plugin: 'com.android.application'
(...)
apply from: '../install.gradle'
apply from: '../bintray.gradle'
main build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
使用这些类的示例项目是here
标签:android,android-studio-2-2,android-maven-plugin,bintray,jcenter 来源: https://codeday.me/bug/20190627/1309078.html