8

I am working on one library project in android. I want to upload my library to the JCenter. I have created bintray account etc & followed all steps which are mentioned here http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en

I did below changes in my application module & library module.

Application Module build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"


    defaultConfig {
        applicationId "com.app.testapp"
        minSdkVersion 8
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
    }


}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile project(':testlib')
}

Library Module build.gradle

apply plugin: 'com.android.library'

ext {
    bintrayRepo = 'maven'
    bintrayName = 'test-sdk'

    publishedGroupId = 'in.test.sdk'
    libraryName = 'testlib'
    artifact = 'test-sdk'

    libraryDescription = 'A wrapper for Facebook Native Like Button (LikeView) on Android'

    siteUrl = 'https://github.com/xyz/testsdk'
    gitUrl = 'https://github.com/xyz/testsdk.git'

    libraryVersion = '1.0.0'

    developerId = 'xyz'
    developerName = 'xyz'
    developerEmail = 'xyz@xyz.xyz'

    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ["Apache-2.0"]
}

version = "1.0.0"
android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 22
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    buildTypes {
        release {
            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
           // proguardFiles 'proguard-project.txt'
        }
        packagingOptions {
            exclude 'META-INF/LICENSE.txt'
        }
    }


}

dependencies {
    compile 'com.android.support:support-v4:22.2.0'
    compile files('libs/gson-2.3.1.jar')
    compile files('libs/android-query-full.0.26.8.jar')
    compile files('libs/httpmime-4.1.1.jar')
    compile files('libs/jackson-annotations-2.5.0.jar')
    compile files('libs/javax.annotation.jar')
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile files('libs/okhttp-2.3.0.jar')
    compile files('libs/okio-1.3.0.jar')
    compile files('libs/retrofit-1.9.0.jar')
}

Project root 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.3'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
        classpath 'com.github.dcendents:android-maven-plugin:1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }


}

allprojects {

    repositories {
        jcenter()
    }
}

When I am doing this gradlew install then I am getting this error

FAILURE: Build failed with an exception.

* What went wrong:          
Task 'install' is ambiguous in root project 'TestApp'. Candidates are: 'installDebug', 'installDebugAndroidTest'.

* Try:                      
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED                

Total time: 11.685 secs   

I spent three days on same but could not get proper solution of it. Please suggest how to resolve it.

user1986760
  • 813
  • 2
  • 10
  • 19
  • ./gradlew installDebug – Stas Parshin Aug 27 '15 at 19:21
  • Hi, Thank a lot, its working but after that i had execute another command that is :- gradlew bintrayUpload **Again got ERROR : ** 'FAILURE: Build failed with an exception. * What went wrong: Task 'bintrayUpload' not found in root project 'TestApp'. BUILD FAILED' – user1986760 Aug 28 '15 at 11:29
  • So edit your question about bintrayUpload problems, or close this and open another question. – Stas Parshin Aug 28 '15 at 12:23
  • Hi Pengrad, i have post the new question as suggested by you, i need your help , Kindly guide me further. New Question [Link] (http://stackoverflow.com/questions/32305239/task-bintrayupload-not-found-in-root-project-while-executing-command-gradlew-b) – user1986760 Aug 31 '15 at 06:51
  • 1
    Hi, I'm facing the ambiguous root project problem. Can you please guide me what am I missing? – Ari May 18 '16 at 10:28
  • I had the same problem. Then I realized I was typing this command in the wrong project. BTW, [here's a working bintrayUploadable android library project](https://github.com/LouisCAD/Splitties) – Louis CAD Sep 11 '16 at 18:57

2 Answers2

8

Perhaps you forgot to add these lines to the end of your Library Module build.gradle:

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
D.M.
  • 325
  • 4
  • 9
2

You are telling gradle to do the 'install' task but it is telling you that there is no 'install' task and gives suggestions of close task matches like 'installDebug'. Basically your plugins do not include an install task. If you want to see all the tasks that are available to you run the command below

gradlew tasks --all
Zahra
  • 2,231
  • 3
  • 21
  • 41
Joe Bob
  • 21
  • 1