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

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"

Related

Which third-party dependencies are declared in the build.gradle of this Android Studio project?

I want to convert this Android Studio project into an Eclipse project.
The way to do it is to copy everything in all src packages and res directory from AS project to Eclipse project, and change the Eclipse project's Manifest file by adding all the additional elements from AS project.
The catch is that I have to do this for all the third party dependencies (declared in build.gradle) on which the AS project depends and then add those library projects to this newly created Eclipse project.
Normally I would do it for each library listed in the dependencies section of build.gradle file of AS project. But for this library project, I don't understand what are the dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
}
I don't understand the first and third line. Please tell me which libraries are declared in first and third line, so that I can copy those projects in Eclipse?
EDIT:
Here is the output of gradlew.bat -q dependencies command:
EDIT 1:
EDIT 2:
For each project module, do the following from the command line:
./gradlew -q dependencies
This will print out a graph of all dependencies the module has.

Android Studio 1.0.1 add external libraries

I have just downloaded Android Studio 1.0.1 and this is the new project structure
and when i see it in the explorer there is a empty libs folder
i want to import 3 external libraries i have, which i want to use.
build.gradle has already defined this
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
but when i copy my libraries in libs folder my project still dont recognize it,
how do i make use of the libs folder and copy my libraries in this folders and use it?
any help?
Edit:
it was a simple question, how to add libraries to project in Android Studio
like we do in eclipse, for eg i have a library project(a folder, not a jar!).
in my case i have a library project 'viewPagerIndicator' (again a Library folder, not a jar!) i have to add it to my project like i use to do it with eclipse by importing project, right click->properties->android->Library->add-> select the library project
PS: i have found the answer now.
suppose my library project name is 'viewPagerIndicator'
- Copy library project on root of my Android Studio Project
- Under build.gradle(under your Android Studio Project folder) write this under dependencies
compile project(':viewPagerIndicator')
- include it in settings.gradle, write:
include ':viewPagerIndicator'
- Sync project with gradle files
this is how project structure look like now:
so sorry that admins stopping the question without understanding it.
First you have to add library project (module) in Android Studio
File -> Import Module
To add library project (module) in build path, click
File -> Project Structure
On the left hand side click on
app -> Dependencies tab -> green + button -> Module dependency
Now select the library project you already added.
For more details refer this link
In My Case to add external library project into android studio 1.1.0
step-1 : File -> Import Module -> set path for library project
step-2 : Set dependencies{} in main projects's build.gradle like,
dependencies {
compile project(':facebookSDK')
compile project(':slidingMenu')
compile project(':SkyconsLibrary')
}

importing ShowcaseView with gradle

I'm trying to use the ShowcaseView project in my app but can't get the project to build.
when I run 'gradle clean installDebug' I get the following error:
A problem occurred evaluating root project 'hows-it-going'.
Could not find method compile() for arguments [project ':ShowcaseView'] on root project 'hows-it-going'.
I'm using gradle 1.11 and Android Studio 0.54.
I've downloaded the source, and imported the project using file -> Import module -> ShowcaseView
which makes my project structure like:
-project
--app
--ShowcaseView
my settings.gradle file looks like:
include ':app', 'ShowcaseView'
and in my project level build.gradle I have the following:
dependencies {
compile project (':ShowcaseView')
}
Any help with how to include this properly would be much appreciated. Thanks.
The latest version of ShowcaseView is available as a .AAR dependency. To use it, add:
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
To your build.gradle file and, under the dependencies block, add:
compile 'com.github.amlcurran.showcaseview:library:5.0.0-SNAPSHOT'
I'll get a stable, non-snapshot, version out soon.
It should actually be
compile 'com.github.amlcurran.showcaseview:library:5.0.0-SNAPSHOT#aar'
That way Maven will use .AAR file
I recently just added ShowcaseView to an Android Studio project, and I hope this can push you in the correct direction.
My file structure looks something like this:
project
app
build.gradle
libraries
showcase
build.gradle
settings.gradle
Add the files from the library
folder
of ShowcaseView to the showcase directory in the libraries
directory.
Add the showcase directory as a module to your project.
Change your app's build.gradle file to include:
dependencies {
compile project(':libraries:showcase')
}
Change your settings.gradle to include:
include ':libraries:showcase'
Sync Project with gradle files
This StackOverflow answer goes over how to do this is much more detail if you have any troubles, but this method works for any library.
The compile dependency on ShowcaseView should likely be defined in app/build.gradle, not in the root project's build.gradle. Unless a project explicitly (configurations block) or implicitly (by applying a plugin such as java) defines a compile configuration, it won't have one, and an attempt to add a compile dependency will result in the error you mentioned.
I added this in build.gradle and it worked
compile 'com.github.amlcurran.showcaseview:library:5.4.3'

Best way to add dependency for Wire using Gradle in Android Studio

I'm using Square's Wire library for my Android app, using Android Studio with Gradle.
I originally added the wire-runtime-1.2.0.jar into a libs folder in my module, and added the dependency to Gradle like this in my build.gradle file:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
That worked fine.
I'm new to Gradle and Android Studio, but based on the way I'm depending on the Google Support and Play Services libraries, I thought I might be able to remove the wire-runtime-1.2.0.jar library from my repository and just declare a dependency like this (the line is from the Maven repository):
dependencies {
compile 'com.squareup.wire:wire:1.0.0'
}
But if I do that then I hit this error:
Gradle: package com.squareup.wire does not exist
Is there a way to set up this dependency without importing the JAR file directly? Or does that only work for libraries that you can install through the SDK Manager?
Some packages, like com.squareup.wire, have multiple artifacts in Maven Central. You need to choose the right one for your needs. In this case, the equivalent of wire-runtime-1.2.0.jar is the wire-runtime artifact, not the wire artifact.
Here's what your dependencies section should look like:
dependencies {
compile 'com.squareup.wire:wire-runtime:1.2.0'
}

Android Studio and AndEngine - package does not exist

I've got problem with adding AndEngine to Google Android Studio IDE.
I downloaded AndEngine from git and extract it to the folder.
In my existing project I clicked File>Project Structure>Modeles
In middle column green plus>new module>empty module and I selected AndEngine folder
In middle column i select my project then Dependencies>green plus at right>Module Dependency and I selected AndEngineModule.
When i try to run it there are errors like this:
Gradle: error: package org.andengine.engine.camera does not exist
I did the same! I am not sure how does it work exactly. But It seems that Android Studio uses libraries 'just for source' to find the libraries and then IDE uses Gradle like external build tool.
So I have created the libs directory in my project and move *.jar files there. I have added libraries files (*.jar) into project dependencies. Than I can use org.andegine package in my project sources but I had still the error so I have added dependencies also into build.gradle.
dependencies {
compile 'com.android.support:support-v4:18.0.0'
//compile files('libs/andengine.jar') // for single file
compile fileTree(dir: 'libs', include: '*.jar') // for all files in directory
}

Categories

Resources