Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you edit a dependency/external library in android studio? [duplicate]

There is a lot of information about adding libraries and dependencies, but I haven't been able to find any useful information on being able to actually edit a library.

I have added https://github.com/jdamcd/android-crop as a dependency in my project, but I would like to edit some of its features, mostly layout related stuff. However, when I go into browse the files Android Studio says "files under the build folder are generated and should not be edited" and when I edit them they are returned back to their pre-edited state once the system builds.

I also tried editing the files in notepad++ and the same problem occurs (they are returned to their pre-edited state on build).

Can someone tell me either how to edit the library or a workaround whereby I can change the layouts/some java without having to copy and paste the entire library into my project to make it editable?

Thanks in advance,

God speed.

Edit: The answer is instead of simply adding the library as a dependency in the build.gradle file using this code: compile 'com.soundcloud.android:android-crop:0.9.10@aar'

You have to add it as a module instead of just an external dependency, then you can edit the files.

If anyone is wondering how follows these steps:

  1. Create library folder (call it whatever you want) in the root directory, i.e. the first folder you go into to get to the app and its contents.
  2. Download the library, unzip it.
  3. Put the folder from step 2 in the folder you created in step 1.
  4. Add the module to the settings.gradle like so: include ':LibraryContainingFolder:ActualLibFolder'
  5. Sync and clean
  6. Go to project structure in Android Studio, click on the main module, normally called app, click on dependencies tab, then click the green plus, then click "Module dependency". The module should appear written as the containing folder and the library folder in it separated by colons 'something:somethingElse'. Add the module.
  7. Sync, clean, buid etc.
like image 531
Micah Simmons Avatar asked May 20 '15 08:05

Micah Simmons


People also ask

Where are dependencies stored Android Studio?

The Gradle build system in Android Studio makes it easy to include external binaries or other library modules to your build as dependencies. The dependencies can be located on your machine or in a remote repository, and any transitive dependencies they declare are automatically included as well.

What is external libraries in Android Studio?

You are developing an Android app on Android Studio, sometimes you want to use an external library for your project, such as a jar file. Common langs is an java library with open source code which is provided by the Apache, it has utility methods for working with String, numbers, concurrency ...


1 Answers

You should add the library as a module in Android Studio, by downloading the code from the Github repository you're interested in (and removing the line under dependencies that you added to build.gradle)

Then follow the steps in this answer: https://stackoverflow.com/a/16639227/1065810

like image 81
Karim Avatar answered Oct 11 '22 18:10

Karim