I'm trying to publish an Android library to jcenter. I've followed https://github.com/danielemaddaluno/gradle-jcenter-publish tutorial. Everything works fine until I try to execute
gradle bintrayUpload
When I do so I get a BUILD FAILED. When I look into the errors I see
package com.android.volley does not exist
Therefore the libraries that I have included as a gradle dependency are not being found
dependencies {
compile 'com.mcxiaoke.volley:library:1.+' (...)
}
The same happends with other libraries included.
How can I fix this problem?
I Attach the module build.gradle
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "0.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.mcxiaoke.volley:library:1.+'
compile 'com.shamanland:fab:0.0.8'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:gridlayout-v7:21.0.3'
}
def siteUrl = "SOME_URL"
def gitUrl = 'SOME_URL'
group = "GROUP_ID"
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name 'NAME'
description = 'DESCRIPTION'
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'MY_ID'
name 'MY_NAME'
email 'MY_EMAIL'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
// https://github.com/bintray/gradle-bintray-plugin
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
// it is the name that appears in bintray when logged
name = "androidupdatechecker"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
version {
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing'
}
// mavenCentralSync {
// sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
// user = properties.getProperty("bintray.oss.user") //OSS user token
// password = properties.getProperty("bintray.oss.password") //OSS user password
// close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
// }
}
}
}
and the project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
}
}
allprojects {
repositories {
jcenter()
}
}
The library is in maven repository, so you need to declare the maven central repository. Add it in your project build.gradle file like this:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
}
}
Please refer to the following:
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
At this point, you need in your local. Join in the properties files,
Bintray. User = XXX
Bintray apikey = XXX
Related
UPDATE2: I was not generating a aar file, now it's included in the package that you can check here: https://github.com/fabrizioiacobucci/range-bar-preference/packages/787218
I see javadoc, sources and aar are there, but when I add the package as dependency in another project I don't even see it in the External Libraries.
UPDATE: This is the problem, I don't see my source files in the downloaded jar:
I recently forked a little project on Github and migrated its old code version to AndroidX and new gradle build.
After some time everything work fine and I was able also to publish the library on Git packages.
However, I tried to declare it as dependency on a different project on my local computer. It downloads fine but when I try to import it in a source file, I cannot find the package:
If I go into the project folder I see the library downloaded and related files.
This is the Project build.gradle file of the published library.
build.gradle (project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
}
}
plugins {
id 'maven-publish'
}
apply from: "${rootDir}/scripts/publish-root.gradle"
apply plugin: 'io.github.gradle-nexus.publish-plugin'
ext {
VERSION = '1.0.0'
DESCRIPTION = 'A range bar that can be used as an android shared preference'
GROUPID = 'com.fabrizioiacobucci.android'
ARTIFACTID = 'range-bar-preference'
GITREPO = 'https://github.com/fabrizioiacobucci/tree/development/range-bar-preference.git'
PROJECTURL = 'https://github.com/fabrizioiacobucci/tree/development/range-bar-preference'
PUBLISHGIT = 1
PUBLISHMAVEN = 0
}
nexusPublishing {
repositories {
sonatype {
stagingProfileId = '1c4ab2dc896731'
//packageGroup = "com.fabrizioiacobucci.android"
username = ossrhUsername
password = ossrhPassword
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
build.gradle (module)
apply plugin: 'com.android.library'
android {
compileSdkVersion 30
buildToolsVersion '31.0.0 rc3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 30
version VERSION
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
versionCode 1
versionName VERSION
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'com.appyvet:materialrangebar:1.3'
implementation 'androidx.appcompat:appcompat:1.2.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.5.1'
}
apply from: "${rootDir}/scripts/publish-module-maven.gradle"
apply from: "${rootDir}/scripts/publish-module-githubpkg.gradle"
publish-module-maven.gradle
apply plugin: 'maven-publish'
apply plugin: 'signing'
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}
task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.srcDirs
classpath = configurations.compile
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
artifacts {
archives androidSourcesJar
archives javadocJar
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
// The coordinates of the library, being set from variables that
// we'll set up later
groupId GROUPID
artifactId ARTIFACTID
version VERSION
artifact("$buildDir/outputs/aar/range-bar-preference-release.aar")
artifact androidSourcesJar
artifact javadocJar
// Mostly self-explanatory metadata
pom {
name = 'Range Bar Preference'
description = 'A range bar that can be used as an android shared preference'
url = PROJECTURL
groupId GROUPID
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
developers {
developer {
id = 'FabrizioIacobucci'
name = 'Fabrizio Iacobucci'
email = 'fabrizio.iacobucci90#mail.com'
}
}
scm {
connection = 'scm:git:github.com/fabrizioiacobucci/range-bar-preference.git'
developerConnection = 'scm:git:ssh://github.com/fabrizioiacobucci/range-bar-preference.git'
url = 'https://github.com/fabrizioiacobucci/range-bar-preference/'
}
}
}
}
}
}
ext["signing.keyId"] = rootProject.ext["signing.keyId"]
ext["signing.password"] = rootProject.ext["signing.password"]
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]
signing {
sign publishing.publications
}
publish-module-githubpkg.gradle
artifacts {
archives androidSourcesJar
archives javadocJar
}
project.publishing {
publications {
maven(MavenPublication) {
groupId = GROUPID
artifactId = ARTIFACTID
version = VERSION
artifact("$buildDir/outputs/aar/range-bar-preference-release.aar")
artifact androidSourcesJar
artifact javadocJar
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'Range Bar Preference'
packaging = 'aar'
description = 'A range bar that can be used as an android shared preference'
url = PROJECTURL
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
developers {
developer {
id = 'FabrizioIacobucci'
name = 'Fabrizio Iacobucci'
email = 'fabrizio.iacobucci90#mail.com'
}
}
scm {
connection = 'scm:git:github.com/fabrizioiacobucci/range-bar-preference/range-bar-preference.git'
developerConnection = 'scm:git:ssh://github.com/fabrizioiacobucci/range-bar-preference/range-bar-preference.git'
url = 'https://github.com/fabrizioiacobucci/range-bar-preference/'
}
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri('https://maven.pkg.github.com/fabrizioiacobucci/range-bar-preference')
credentials {
username = System.getenv("GITHUB_USER")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
I don't know if there is anything else relevant to share, please let me know in case.
Do you have any idea what am I missing?
Thanks a lot in advance for any help.
As promised I forked the original project upgraded to android and then all the dependencies to the latest.
For the fast release of SDK to do the POC, I released it to jitpack.io
How to add the new library as a dependency.
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add this to your app module dependencies:
dependencies {
implementation 'com.github.dk19121991:range-bar-preference:0.0.7'
}
I did try it myself and it's working fine for me, I updated the app module in my forked version to use the library from jitpack only, and it's working smoothly.
Please try the library and let me know if you feel anything else you need.
https://github.com/dk19121991/range-bar-preference
import com.nfx.android.rangebarpreference
change fabrizioiacobucci to nfx will solve your poblem
Hi so I'm following the github site of Gradle Bintray Plugin https://github.com/bintray/gradle-bintray-plugin#readme tutorial however I don't quite understand the publications part. Can anyone help me with this? I'am currently working on bintray version 1.7.3.
Update:
I was able to upload successfully in bintray. However my current problem now is when downloading it in other projects. I have errors when syncing gradle :
-Could not find android-dbpatcher.jar(sirqo:android-dbpatcher:0.0.1).
-Error: Searched in the following locations:
http://sirqo.bintray.com/Android-DBPatcher/sirqo/android-dbpatcher/0.0.1/android-dbpatcher-0.0.1.jar
Update2:
For reference this is my gradle.build in my module
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso- core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.volley:volley:1.0.0'
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
group = 'xxxx'
version = '0.0.1'
install {
repositories.mavenInstaller {
pom.project {
name 'android-dbpatcher'
description 'A library for updating SQLite database in android.'
url 'https://sirqo.bintray.com/Android-DBPatcher'
inceptionYear '2016'
packaging 'aar'
groupId 'xxxx'
artifactId 'android-dbpatcher'
version '0.0.1'
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id 'xxxx'
name 'xxxxx'
email 'xxxxxx#gmail.com'
}
}
}
}
}
Properties bintrayProperties = new Properties()
bintrayProperties.load(project.rootProject.file('bintray.properties').newDa taInputStream())
bintray {
user = bintrayProperties.getProperty('user')
key = bintrayProperties.get('key')
configurations = ['archives']
pkg {
repo = 'Android-DBPatcher'
name = 'android-dbpatcher'
userOrg = 'xxxx'
vcsUrl = 'https://github.com/sirqo/android-dbpatcher'
publish = true
version {
name = '0.0.1'
desc = 'Android SQLite Database Patcher'
released = new Date()
vcsTag = 'v0.0.1'
}
}
}
So I figured it out. For reference I'll share my code.
For my Project gradle.build
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.jfrog.bintray" version "1.7.3"
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And for my module gradle.build
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.volley:volley:1.0.0'
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath +=project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
group = 'xxxx' //bintray org/group name
version = '0.0.1' //version
install {
repositories.mavenInstaller {
pom.project {
name 'xxxxx' //package name
description 'A library for updating SQLite database in android.'
url 'xxxxx'
inceptionYear '2016'
packaging 'aar'
groupId 'xxxx' //group/org id
artifactId 'xxxx' //your android module name
version '0.0.1'
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id 'xxxxx' //developer username
name 'xxxxxx' //developer name
email 'xxxxxx#gmail.com' //developer email
}
}
scm {
connection 'xxxxxx' // YOUR GIT REPO
developerConnection 'xxxxxx' // YOUR GIT REPO
url 'xxxxxxx' // YOUR SITE
}
}
}
}
Properties bintrayProperties = new Properties()
bintrayProperties.load(project.rootProject.file('bintray.properties').newDataInputStream())
bintray {
user = bintrayProperties.getProperty('user')
key = bintrayProperties.get('key')
configurations = ['archives']
pkg {
repo = 'xxxxxx' //Bintray repository
name = 'xxxxxx' //Bintray Package name
userOrg = 'xxxxx'
licenses = ['Apache-2.0']
vcsUrl = 'xxxxxxxx'
publish = true
version {
name = '0.0.1' //version
desc = 'xxxxxx' //Description
released = new Date()
vcsTag = 'v0.0.1'
}
}
}
After this open the android terminal below in your android studio and enter this command
./gradlew install
if there is some errors you can append the command with --debug and re-enter the command to trace the error
//if nothing else fail issue this command
./gradlew bintrayUpload
*again if there is an error you can use the command and append with --debug to trace it.
after all these you will recieve an email or something and then you can proceed to downloading your library in other projects. Happy coding!
i frist import Mudole and add these code to my project build.gradel
dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.github.lzyzsd:circleprogress:1.1.0#aar'
}
and
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
but mudole build.gradle have errore
Error:(2, 0) Cause:
org/gradle/api/publication/maven/internal/DefaultMavenFactory Open File
and this mudele gradle:
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
version = "1.2.0"
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 10
targetSdkVersion 21
versionCode 5
versionName version
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
def siteUrl = 'https://github.com/lzyzsd/CircleProgress'
def gitUrl = 'https://github.com/lzyzsd/CircleProgress.git'
group = "com.github.lzyzsd.circleprogress"
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name 'Circle Progress, Donut Progress, Arc Progress'
url siteUrl
// Set your license
licenses {
license {
name 'MIT'
url 'http://opensource.org/licenses/MIT'
}
}
developers {
developer {
id 'lzyzsd'
name 'Bruce Lee'
email 'bruceinpeking#gmail.com'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
name = "CircleProgress"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["MIT"]
publish = true
}
}
apply plugin: 'maven'
i download mudole from https://github.com/lzyzsd/CircleProgress
just change version gradle to 1.0
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
}
You need to update gradle plugin and version.
Update gradle plugin by Replacing
apply plugin: 'android-maven'
with
apply plugin: 'com.github.dcendents.android-maven'
and update gradle version by adding this :
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
and sync project.
I get following error while running gradlew install.
Failed to capture snapshot of input files for task 'javadoc' during up-to-date check. See stacktrace for details.
Could not normalize path for file 'C:\android\sdk\platforms\android-23\android.jar;C:\android\sdk\platforms\android-23\optional\org.apache.http.legacy.jar'
The project's build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
// 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
}
The library module's build.gradle:
apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'
ext {
bintrayRepo = 'maven'
bintrayName = 'befrest'
publishedGroupId = 'com.oddrun.libraries'
libraryName = 'Befrest'
artifact = 'befrest'
libraryDescription = 'Simple Push Notification Library For Android'
siteUrl = 'https://github.com/hojjat-imani/PushNotif'
gitUrl = 'https://github.com/hojjat-imani/PushNotif.git'
libraryVersion = '0.0.1'
developerId = 'hojjat-imani'
developerName = 'Hojjat Imani'
developerEmail = 'imani.hojjat95#gmail.com'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 0
versionName "0.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
}
version = libraryVersion
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
// Bintray
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = bintrayRepo
name = bintrayName
desc = libraryDescription
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
publish = true
publicDownloadNumbers = true
version {
desc = libraryDescription
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password")
//Optional. The passphrase for GPG signing'
}
}
}
}
group = publishedGroupId // Maven Group ID for the artifact
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
groupId publishedGroupId
artifactId artifact
// Add your description here
name libraryName
description libraryDescription
url siteUrl
// Set your license
licenses {
license {
name licenseName
url licenseUrl
}
}
developers {
developer {
id developerId
name developerName
email developerEmail
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
You can add org.apache.http.legacy.jar in your libs folder.
You can find this jar in Android/Sdk/platforms/android-23/optional
I also added this line to my app.gradle file
compile files('libs/org.apache.http.legacy.jar')
But if you're using more libraries, you can use this way
compile fileTree(dir: 'libs', include: ['*.jar'])
This resolved all my errors that were caused because google removed support of Apache HTTP client. Do not changed compileSdkVersion 23 to 22, I think this solution is better.
There seems to be a problem with apache http in android 23.
Just changing compileSdkVersion 23 to 22 and removing useLibrary 'org.apache.http.legacy' solved the problem.
I am trying to upload my Library to JCenter Repository .
I followed this tutorial :
https://www.virag.si/2015/01/publishing-gradle-android-library-to-jcenter/
My build.gradle for library after running gradlew bintrayUpload command.
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
// This is the library version used when deploying the artifact
version = "1.0.0"
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
}
def siteUrl = 'https://github.com/vipulasri/Layout-to-Image'
def gitUrl = 'https://github.com/vipulasri/Layout-to-Image.git'
group = "com.github.vipulasri"
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name 'Layout to Image'
description = 'The project aims to convert your Android Layout Xml to Image'
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'vipulasri'
name 'Vipul Asri'
email 'vipulasri.2007#gmail.com'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
dependencies {
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
task findConventions << {
println project.getConvention()
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
// it is the name that appears in bintray when logged
name = "layouttoimage"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ['Apache-2.0']
publish = true
}
}
I got Following error :
Publications(s) specified but no publications exist in project :library.
:app:bintrayUpload FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Some problems were found with the configuration of task ':app:bintrayUpload'.
> No value has been specified for property 'packageName'.
> No value has been specified for property 'repoName'.
> No value has been specified for property 'apiKey'.
> No value has been specified for property 'user'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I just encouter this problem, my solution is, edit the project top build.gradle, enable classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2", and disable //plugins {
// id "com.jfrog.bintray" version "1.2"
//}
It works for me, hope helpful for you.
Your Top Level Build.gradle should contain this code in order to successfully build the gradle :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}