toto_tata
toto_tata

Reputation: 15402

Android Studio : how do 'dependencies' work ? How to update a library?

I am a newbie with Android Studio.

I integrated this library https://github.com/2dxgujun/AndroidTagGroup in my project.

All what I had to to is to follow their instructions and thus to add the following line in the 'app gradle file' (in the 'dependencies'):

compile 'me.gujun.android.taggroup:library:1.4@aar'

Then click on "sync" at the top right of the Android Studio window of the app gradle file. It works properly ; great !

Nevertheless, I don't really understand the following things :

1) What does "library:1.4@aar" mean ? Is it a single library file ? Where is it located in the folders ?

2) How does Android Studio know where this library is located on my disk ? I copied/pasted the library folder at the root of the folder where I have all my Android projects on my disk ; is it the default location where Android Studio goes to find libraries ?

3) How should I do if I want to modify something in this library and recompile it ? For example, I modified 13sp (in styles.xml) to 30sp, recompiled the library with "./gradlew assembleDebug" (as mentioned on GitHub) but it has no impact on my project even after a clean/build...why ? By the way what does "./gradlew assembleDebug" mean ?

Thanks for your help !

Upvotes: 3

Views: 1305

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191844

What does "library:1.4@aar" mean ? Is it a single library file ?

Pulls an AAR file from JCenter or Maven

In the case of a Maven project, this dependency is expressed in a pom.xml format like so

<groupId>me.gujun.android.taggroup</groupId>
<artifactId>library</artifactId>
<version>1.4</version>

As you see, you have the artifact id as "library" and "1.4" is just a version name.

How does Android Studio know where this library is located on my disk ?

In the build.gradle file, you'll have a section like this.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

allprojects {
    repositories {
        jcenter()
        // mavenCentral()
        // mavenLocal()    // Some variant of these. 'jcenter' is the default
    }

Depends on your OS, but there is a .gradle directory or .m2 directory in your home folder where all Gradle & Maven dependencies are downloaded.

For example, Gson, for me is at

~/.m2/repository/com/google/code/gson/gson/2.6.2/gson-2.6.2.jar

if I want to modify something in this library and recompile it ?

Probably too broad for this post, but you would no longer use

compile 'me.gujun.android.taggroup:library:1.4@aar'

Because that will always use the Github sources, not your changes. You would need to clone the repo and use compile project feature of Gradle.

What does "./gradlew assembleDebug" mean ?

Run the assemble task for the debug build type of your project using the Gradle wrapper.

Upvotes: 4

Related Questions