0

I first added the android support library and tested that I could use it. However when I add Android Better Pickers in this maven repository I get the following error:

Gradle 'bumble' project refresh failed: Could not find com.google.android:support-v4:18. Required by: myapp:app:unspecified com.doomonafireball.betterpickers:library:1.4.2

This is how I set up my dependencies in the build.gradle located in MyProject -> app.

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.doomonafireball.betterpickers:library:1.4.2'
}

Android Better Pickers has the following in it's build.gradle and is packaged as an aar.

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.nineoldandroids:library:2.4.0'
}

Anyone know of a solution?

EDIT

Android better pickers now has gradle support since v 1.5! Now it is really easy adding it as a library, just follow there guide and don't forget to do a clean AND gradle sync after you change your build.gradle. Parts of the answers to this question still applies for none gradle projects I however.

Simon Bengtsson
  • 7,573
  • 3
  • 58
  • 87

1 Answers1

2

First Make sure your are pointing to right sdk in File >Project Structure >Android SDK

In order to use Support Jar you have to install Android Support Repository from SDK Manager. SDK manager icon is available in Android Studio tool bar.

enter image description here

Things you should know for knowledge :

1.There is no need to add any dependency in your main module, if that is already added in any one of your library module already. So remove support dependency from your main module.

Make it something like this :

 dependencies {
         compile 'com.doomonafireball.betterpickers:library:1.4.2'
 }

2.There is some issue going on in dependency management in android studio (0.4.2) which is fixed for Android Studio (0.4.3) but till the release check this as well For any dependency related issues.

Import Google Play Services library in Android Studio

EDIT :

I have checked the github repository there is no gradle dependency for date picker.

So do the following

  1. Download Repository from github

  2. Copy the library directory inside root of your project or make a directory and keep all your libraries inside that.The below configuration is for direct in root and I have renamed "library "to datepickerlibrary

  3. Modify the build.gradle comes with library

build.gradle inside data picker library module

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}

apply plugin: 'android-library'

android {
    compileSdkVersion 17
    buildToolsVersion '19.0.0'

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}
apply plugin: 'maven'
apply plugin: 'signing'

version = "1.4.0"
isReleaseVersion = !version.endsWith("SNAPSHOT")
group = "com.doomonafireball.betterpickers"

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.nineoldandroids:library:2.4.0'
}

Dependency in your main module's build.gradle should be like :

dependencies {

    compile project(':datepickerlibrary')   //if it is inside some sub directory you can give path like ':libraries:datepickerlibrary' depends on you

}

Add this line inside settings.gradle which is located in root of your Project directory:

include ':datepickerlibrary'

After these all checks, Do sync your project with gradle.

It worked for me, let me know if any issue comes.

ORIGINAL ASKER'S NOTES

I ended up doing something similar to the above and it worked great! What I did as a summary:

  1. Downloaded and manually added the library as a dependency in Android Studio
  2. Removed the following from the library's build.gradle (got a sonytype class not found exception or similar)

    beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
    
    repository(url: sonatypeRepo) {
        authentication(userName: sonatypeUsername,
                password: sonatypePassword)
    }
    
  3. Updated the library's SDK version to match the one I had installed.

Community
  • 1
  • 1
Piyush Agarwal
  • 25,608
  • 8
  • 98
  • 111
  • I tested that I had the Android Support Library set up correctly first and it works great. However, when I add Android Better pickers I get the error message above. I tested including ActionBarSherlock now which also has a dependency of the Android Support library and it works great so I will rephrase my question soon. Would be great if you could take a second look! – Simon Bengtsson Jan 20 '14 at 12:43
  • That is what I ended up doing. Do you know how you can tell if a project can be used as a gradle dependency? Looking at the Android Better Pickers maven repo you can find a Gradle link and on github they include a build.gradle which made me confused. If you don't mind I will add to your answer a bit as I ran into other problems as well. – Simon Bengtsson Jan 20 '14 at 19:17
  • @SimonBengtsson if above answer solved your issue go ahead to accept, so It could help others. And for any other issues better to put a new question so others can also answer. It will be helpful for them who all are having the same issues. If the issue is in same context you can go ahead. – Piyush Agarwal Jan 20 '14 at 19:38
  • 1
    Of course, wanted to add some notes about what I did first though. – Simon Bengtsson Jan 20 '14 at 19:54
  • 1
    Ok no problem add them. – Piyush Agarwal Jan 20 '14 at 19:56