简体   繁体   English

Android Studio 2.2.2将我的应用程序模块作为库发布到具有Bintray存储库的jcenter

[英]Android studio 2.2.2 publish my app module as library to jcenter with bintray repository

Here, I have done qr code scan project successfully. 在这里,我已经成功完成了二维码扫描项目。 i have used for qrcodereaderview 1.0.0 v url repository library. 我已经使用了qrcodereaderview 1.0.0 v网址存储库。 this is my dependency. 这是我的依赖。

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')
}

I have only one app module in my project.I want to upload this project as a library(.AAR) to jcenter repository. 我的项目中只有一个应用程序模块。我想将此项目作为库(.AAR)上传到jcenter存储库。

I have tried for some jcenter uploading steps and I got Successful upload response also from bintrayupload. 我尝试了一些jcenter上传步骤,并且bintrayupload也获得了成功的上传响应。

For this reason, I have created Github login and created project url. 因此,我创建了Github登录名并创建了项目URL。 but, I did not upload my project code into github. 但是,我没有将项目代码上传到github中。 I have given empty project url only in build.gradle. 我只在build.gradle中给出了空的项目URL。

but, when I saw in bintray repository.There is no code update/version change on my bintray maven repository. 但是,当我在Bintray存储库中看到时,我的Bintray Maven存储库没有代码更新/版本更改。

Android Studio Project convert as .aar(library) file and uploading to jcenter repository in below steps following. Android Studio Project转换为.aar(library)文件,并按照以下步骤将其上传到jcenter存储库。

1). 1)。 I have changed main app module build.gradle files for three changes. 我将主应用程序模块build.gradle文件更改为三个更改。
Changed library plugin ,commented application id and changed manifest file launcher activity . 更改了库插件 ,注释了应用程序ID,更改了清单文件启动器活动

My app module build.gradle file: 我的应用程序模块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'

My Manifest file: 我的清单文件:

 <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 file: gradle.properties文件:

bintray.user=vhk*********6
bintray.apikey=***1f************************98f51***

2). 2)。 Next Steps for upload my studio project to bintray.com. 将我的Studio项目上传到bintray.com的下一步。 I have used three command for that. 我为此使用了三个命令。

-gradleW clean
BUILD SUCCESSFUL
-gradleW install
BUILD SUCCESSFUL
-gradleW bintrayupload
BUILD SUCCESSFUL

After executed the above three commands, when i saw in my bintray repository, there is no change in my repository. 执行上述三个命令后,当我在我的Bintray存储库中看到时,我的存储库中没有任何更改。

My repository's screenshot 我的存储库的屏幕截图

在此处输入图片说明

I dont know exactly what step is missing. 我不知道到底缺少什么步骤。 Can anyone help to come out this error. 任何人都可以帮助解决此错误。

Overall I want to Publish my Studio2.2.2 project(converted as .aar library) to jcenter repository and need to get my project url this like. 总的来说,我想将Studio2.2.2项目(转换为.aar库)发布到jcenter存储库,并且需要像这样获取我的项目url。 ( when i tried this url also in other new project in dependencies, getting error while sync,because, code/.aar not upload in repository) (当我也在依赖项的其他新项目中尝试此URL时,同步时也会出错,因为代码/.aar没有上传到存储库中)

I have one pending final steps is there. 我有一个待定的最后步骤。 once code is uploaded, need to jcenter sync is pending in bintray repos.then only, I can able to use the above url to other New Project. 代码上传后,需要在bintray仓库中进行jcenter同步处理。然后,我就可以将上述url用于其他New Project。

compile 'com.test.testsdkproj16:app:1.0.0' 

In your question you have written, that you keep credientials to bintray account in gradle.properties : 在你的问题你写,你保持credientials到bintray帐户gradle.properties

bintray.user=vhk*********6
bintray.apikey=***1f************************98f51***

If you look into the source file from: 如果您从以下位置查看源文件:

https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle

You will see the following lines: 您将看到以下几行:

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")

You have put the credientials in the wrong file. 您已将凭证放入错误的文件中。 They should be in local.properties 它们应该在local.properties

EDIT After long discussion finally the project was published to bintray. 编辑经过长时间的讨论,最终该项目被发布到Bintray。 The problem here was that the user was publishing to another organisation project. 这里的问题是用户正在发布到另一个组织项目。 So indeed, the answer made by @gba was correct. 所以确实,@ gba的回答是正确的。 However, @harikrishnan was advised to download bintray.gradle and install.gradle to the project and modify them. 然而,@harikrishnan被告知下载bintray.gradleinstall.gradle到项目并对其进行修改。 Here is how they should look: 它们的外观如下:

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 : 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's build.gradle : 应用程序的build.gradle

apply plugin: 'com.android.application'

(...)

apply from: '../install.gradle'
apply from: '../bintray.gradle'

main build.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
}

A sample project that utilises those classes is here 利用这些类的示例项目在这里

seems like you are missing the userOrg parameter. 好像您缺少userOrg参数。 Please look at the following threads: 请查看以下线程:

HTTP/1.1 401 Unauthorized when uploading binary on bintray 在Bintray上上传二进制文件时未经授权的HTTP / 1.1 401

Trouble Publishing Android Studio Library on jCenter with Bintray 使用Bintray在jCenter上发布Android Studio库时遇到问题

publish my android aar to jcenter 将我的android aar发布到jcenter

In short, your repo is under your org and not under your user account. 简而言之,您的存储库位于组织机构下,而不是用户帐户下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM