I have a groovy project with
dependencies {
compile project(':app')
}
where app is an android project.
When I run ./gradlew dependecies
compile - Compile classpath for source set 'main'.
\--- project :app
is all that is printed out.
Why are all the dependencies from the app project being printed out?
Is there a way to get all of the dependencies from this project and add them to this project?
I was able to fix my problem with
dependencies {
compile project(':app').configurations.compile.dependencies
}
Related
I tried using
./gradlew androidDependencies
but that shows all dependencies. I just want to see only module dependencies, e.g. as defined in all build.gradles
dependencies {
implementation project(':moduleA')
implementation project(':moduleB')
implementation project(':moduleC')
}
You mean like
gradle moduleA:dependencies
This should show the dependencies related to moduleA
For the whole dependencies Tree with no module selected
gradle dependencies
https://github.com/vanniktech/gradle-dependency-graph-generator-plugin
You can use this plugin to create "your project module dependency graph"
./gradlew generateProjectDependencyGraph
or "whole dependency graph".
./gradlew generateDependencyGraph
i have created an android library AAR in android studio 2.1.3 in which i use the following dependencies:
compile 'com.google.android.gms:play-services-vision:9.4.0+'
compile 'com.google.android.gms:play-services-wearable:9.4.0+'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
now i am using this aar in an application but those dependencies were failing unless i add them to the dependencies of the new app.
i search here and i found that i need to add the following line:
compile (project(':LIBNAME-release')) {transitive = true}
but this didn't work. is there something i missed? or is it related to the obfuscation i did to the aar file? or is it a must to add these dependencies to the app?
Try to compile you project first:
dependencies {
compile project(':Name-Of-Your-Project')
}
This is Ashton Engberg's suggestion from that post
I have created an android project its name is a Sample app I also created a library module inside the Sample app project. The sample app has a dependency on other libraries so I have added required jar files inside the libs folder of the Sample app. the same jar files are required inside the module as well.
how can I add the dependency for the module to refer to the sample app's libs folder?
I have tried this below but every time giving a Duplicate copy file exception.
repositories {
flatDir { dirs '../libs' }
}
compile fileTree(dir: '../libs', include: '*.jar')
Add this to your app's build.gradle:
dependencies {
....
compile project(':module-name')
}
If you want a library (*.jar / *.aar) to be visible to the entire project, then you will need to make it's location visible to all projects.
Project's gradle file:
allprojects {
repositories {
jcenter()
flatDir {
// This is where the *.jar or *.aar should be located
dirs "$rootProject.projectDir/libs"
}
}
}
Example
With the following directory structure:
SampleApp/
|--- app/
|--- libs/
\--- myLibrary.aar
|--- myModule/
|--- build.gradle (<-- Project's gradle file)
\--- settings.gradle
And the following dependencies graph:
compile - Classpath for compiling the main sources.
|--- project :myModule
\--- :myLibrary:
\--- :myLibrary:
then
SampleApp's build.gradle:
dependencies {
compile project (":myModule")
compile (name: 'myLibrary', ext: 'aar')
// ...
}
myModule's build.gradle:
dependencies {
compile (name: 'myLibrary', ext: 'aar')
// ...
}
In app level build.gradel
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v13:22.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile files('lib/universal-image-loader-1.9.3.jar')
}
In order to add Module dependency in android studio, follow below instruction :
You should put your library modules inside the Application Project. In order to specify a module dependency, simply:
Right click on Application->Open Module Settings
Click on the '+' icon
Select the root directory for your library module you'd like to add.
Follow the prompts
Then, this module will show up in your project. Then, you need to add it to Application as a library dependency. Once again, in your Module Settings:
Select your Application module
Select the Dependencies tab on the right
Click the '+' icon on the bottom
Select Module Dependency
Select your desired library module
if you are using kotlin DSL add this to build.gradle.kts file:
dependencies {
....
implementation(project(":your-library-module"))
}
Trying to build Google Maps Android API utility library, I have SDK 23 installed and all the right SDK tools. At first when i imported the project I wasn't able to run it, the run button was greyed out. I then added "apply plugin: 'com.android.application'" to the top of gradle file. Then when i try to compile, I get the Failed to resolve: com.google.maps.android:android-maps-utils:0.4+ error in my build gradle(module: library).
dependencies {
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4+'
}
dependencies section in original android-maps-utils-master/demo/build.gradle contains:
dependencies {
compile project(':library')
// Or, fetch from Maven:
// compile 'com.google.maps.android:android-maps-utils:0.3+'
compile 'com.google.android.gms:play-services-maps:8.4.0'
}
So:
You may use it as it is. Library android-maps-utils will be compiled from "compile project(':library')". It works for me. Or
You may comment "compile project(':library')", then uncomment "compile 'com.google.maps.android:android-maps-utils:0.3+'" and the library will be downloaded from maven repository. But )
Gradle has no idea where it is. So you should add the followilg code:
allprojects {
repositories {
mavenCentral()
}
}
into the file android-maps-utils-master/build.gradle
This actually works:
Comment out the other dependencies where any google Api is called.
Specifically, firebase ( compile 'com.google.firebase:firebase-ads:9.0.1' ) and gms( compile 'com.google.android.gms:play-services-maps:9.0.1' ).
Now go for 'Sync Now'.
You may encounter some other error, like some value is missing.
Ignore the errors, uncomment the commented dependencies and Voila! It all has been figured out by our dear Gradle!
I'm trying to setup nhaarman/ListViewAnimations inside of Android Studio 1.1.0.
From Setup:
Add the following to your build.gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0#aar'
}
yet Android Studio says:
Gradle project sync failed. Basic functionality (e.g. editing,
debugging) will not work properly.
Error:(26, 0) Gradle DSL method not found: 'compile()'
Possible causes:<ul><li>The project 'X' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
You are adding these dependencies in the top level build.gradle file.
You have to add these lines in the module build.gradle file.
root
build.gradle //top level
app
build.gradle //module level
After adding those lines to:
build.gradle (Module: app)
instead of
build.gradle (Project: app)
the error is gone.
Try this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0'
}
Try removing #arr. worked for me.
//ListView Animations
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0'