Add android-numberpicker backport to Android Studio Gradle project - android

I want to use this library in my Android Studio project https://github.com/SimonVT/android-numberpicker. I can't for the life of me figure out how to add it to my project. Can someone just outline how this would work? I've only ever added libraries that were contained in jar files.

In build.gradle, use:
dependencies {
compile group: 'net.simonvt', name: 'android-numberpicker-parent', version: '1.0.0'
}

If you are using new gradle build system (and you really should), just add
compile 'net.simonvt:android-numberpicker:1.0.0'
to your build.gradle's dependencies section.

I found a forked version of this library which can be imported from source as a module in Android Studio. It is available here:
https://github.com/heavyplayer/android-numberpicker

Related

Android studio IDE choose dependency dialog

I am unable select any external library in my project other than com.google libs from the 'Choose Dependency libraries' dialog in the android studio 3.01.
I am not sure of any missing gradle settings and this issue exists even in any new Android studio project. Any help in resolving this is appreciated.
Just add this in your build.gradle file-:
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
Simply add below code in build.gradle file.
dependencies {
compile 'com.squareup.retrofit2:retrofit:2.3.0'
}
And if you want add other third party library then visit it's doc section you find gradle dependecy for it.
Read more about add third library in Android Studio projects.
How to use/import library in Android Studio

Android Studio Gradle dependency doesn't show up in External Libraries

I'm using Android Studio 3.0.1 and I'm trying to add an online dependency and while Gradle initially syncs without a problem it doesn't show my dependency in External Libraries and my code that references the dependency doesn't work.
Here's a snippet of what my build.gradle file looks like:
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/groups/public/' }
}
dependencies {
compile group: 'com.fortysevendeg.android', name: 'swipelistview', version: '1.0-SNAPSHOT'
}
I'm pretty new to android development (took over an existing project from a dev who quit without leaving any documentation) so I'm not sure if this is a mistake with how to add a project dependency or if there is a problem with the dependency that I'm trying to add. Any help would be greatly appreciated!
I was able to get this to work by changing the dependency declaration to:
compile group: 'com.fortysevendeg.android', name: 'swipelistview', version: '1.0-SNAPSHOT', classifier: 'jar-with-dependencies'
The library artifacts up on the repository include an apklib and a JAR with a special classifier. The apklib format is not supported by Android Studio, and unfortunately the classifier on the JAR means that it's not accessible simply using the group-name-version format when declaring dependencies.
Your build.gradle file seems fine. If you want to keep the library specified as an external library, you can try and define the dependency using the alternative notation, replace:
compile group: 'com.fortysevendeg.android', name: 'swipelistview', version: '1.0-SNAPSHOT'
with:
compile 'com.fortysevendeg.android:swipelistview:1.0-SNAPSHOT'
The alternative approach is to download the jar file yourself and use it as a local dependency. If you navigate to the maven repository you can inspect the package which is included as a dependency and download the jar directly. Place the jar file in the libs folder of your project and add the following to your build.gradle file:
compile fileTree(dir: 'libs', include: ['*.jar'])
For further details on how to configure the dependencies of your gradle project, check out the Android Studio documentation here.
Based on the information you have provided, this should fix your issues. If this does not solve the error then there may be other issues with the project.
Your dependencies should not placed in the top-level build.gradle file where the repositories are defined. There is even a comment in that file that says so, by default.
You app dependencies should be the module's build.gradle along with the others like android-support
Additionally, that library is very old, and is a SNAPSHOT build, meaning it isn't meant to be generally used in a release environment. You should find an alternative... And there are plenty of other ListView swiping ones

Add an Android binary library to an Eclipse project without gradle

I have a legacy eclipse Android project. The classic old way without gradle.
Suppose I found a library I want to integrate with, for example 'commons-codec', than quoting from gradle manual https://docs.gradle.org/current/userguide/organizing_build_logic.html#sec:external_dependencies, I need to paste the below in my gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'commons-codec', name: 'commons-codec', version: '1.2'
}
}
Now my eclipse project does not use gradle.
The Question: Is there a way to get the binary lib & integrate with it in eclipse (something similar to download the library's jar and add it)? I know this question is bizarre since I need the jar to be in the repository, but I want to be sure I'm not overlooking anything.
Many Thanks!
If you're just using a jar, you can include it in the libs folder of the Eclipse project. But that's code only. If there's resources in the library, you'd need to build an Android Library project out of it and include that in your project. Which I'm not sure how you'd do without code.
If you are having .jar file the simply right click on your project then
Properties-->Java Build Path-->Libraries-->Add Jar/ Add External Jar--> Apply
And if you are having library in your workspace then
Properties-->Android-->Add-->locate your library-->Apply

How to import github library in eclipse

I am trying to use material designing library https://github.com/drakeet/MaterialDialog from github in my eclipse but I didnt found any jar file in this library project. So how can I use this library in my project in eclipse
If you have a Gradle build, as mentioned in the README, you just add:
dependencies {
compile 'me.drakeet.materialdialog:library:1.2.2'
}
As explained in the blog post, this looks like (in Android Studio)
You have to convert this library project from gradle to eclipse. You can get many links over the web for it. Try this.
The library project you are looking is build into android studio(Gradle). So I recommend you to use android studio instead of eclipse.
I recommend you to use Android Studio with Gradle support by default. But if you want use Eclipse download Gradle plugin and add this lib as dependency
dependencies {
compile 'me.drakeet.materialdialog:library:1.2.2'
}

How to find the version of library from Gradle Dependency? Android Studio

Question:
How do I find the version of libraries that are being used when my Gradle file mentions a dependency using the '+' operator in the version number of the dependency?
Context
My build.gradle under app module reads like so:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:5.+'
}
What is the version of the play-services library that is being used here?
You can use gradles' build-in 'dependencyInsight' task to query the resolved version of your dependency:
gradle dependencyInsight --configuration compile --dependency com.google.android.gms:play-services
If you want to get an overview for all your dependencies in one go, you can do
gradle dependencies
If you use the gradle wrapper you must use ./gradlew instead of gradle
Look under .idea folder of your project
In the Project Pane on the left, browse to .idea/libraries
All the library dependencies that your project has have been mentioned, with each one getting its own xml file. You can see the version number included in the xml file title. The xml itself has the library file path.
(OR) Use Gradle's built in task to get dependencies
See steps here: https://stackoverflow.com/a/25236208/1311745
Android Gradle Dependency library version
Android Studio 3.1.4
You are able to use Project view
In Android Studio, in the build.graddle app, select the version and press ALT + ENTER, then select "Replace with specifyc version"

Categories

Resources