[英]Android studio 2.2.2 publish my app module as library to jcenter with bintray repository
在這里,我已經成功完成了二維碼掃描項目。 我已經使用了qrcodereaderview 1.0.0 v網址存儲庫。 這是我的依賴。
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')
}
我的項目中只有一個應用程序模塊。我想將此項目作為庫(.AAR)上傳到jcenter存儲庫。
我嘗試了一些jcenter上傳步驟,並且bintrayupload也獲得了成功的上傳響應。
因此,我創建了Github登錄名並創建了項目URL。 但是,我沒有將項目代碼上傳到github中。 我只在build.gradle中給出了空的項目URL。
但是,當我在Bintray存儲庫中看到時,我的Bintray Maven存儲庫沒有代碼更新/版本更改。
Android Studio Project轉換為.aar(library)文件,並按照以下步驟將其上傳到jcenter存儲庫。
1)。 我將主應用程序模塊build.gradle文件更改為三個更改。
更改了庫插件 ,注釋了應用程序ID,並更改了清單文件啟動器活動 。
我的應用程序模塊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)。 將我的Studio項目上傳到bintray.com的下一步。 我為此使用了三個命令。
-gradleW clean
BUILD SUCCESSFUL
-gradleW install
BUILD SUCCESSFUL
-gradleW bintrayupload
BUILD SUCCESSFUL
執行上述三個命令后,當我在我的Bintray存儲庫中看到時,我的存儲庫中沒有任何更改。
我的存儲庫的屏幕截圖
我不知道到底缺少什么步驟。 任何人都可以幫助解決此錯誤。
總的來說,我想將Studio2.2.2項目(轉換為.aar庫)發布到jcenter存儲庫,並且需要像這樣獲取我的項目url。 (當我也在依賴項的其他新項目中嘗試此URL時,同步時也會出錯,因為代碼/.aar沒有上傳到存儲庫中)
我有一個待定的最后步驟。 代碼上傳后,需要在bintray倉庫中進行jcenter同步處理。然后,我就可以將上述url用於其他New Project。
compile 'com.test.testsdkproj16:app:1.0.0'
在你的問題你寫,你保持credientials到bintray帳戶gradle.properties
:
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"]
}
應用程序的build.gradle
:
apply plugin: 'com.android.application'
(...)
apply from: '../install.gradle'
apply from: '../bintray.gradle'
主要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
}
利用這些類的示例項目在這里
好像您缺少userOrg參數。 請查看以下線程:
在Bintray上上傳二進制文件時未經授權的HTTP / 1.1 401
使用Bintray在jCenter上發布Android Studio庫時遇到問題
簡而言之,您的存儲庫位於組織機構下,而不是用戶帳戶下。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.