8

The problem

Under "External Libraries" in the project view of an Android Studio project I have these libraries "stax-stax-api:1.0.1@jar" and "xpp3:xpp3:1.1.3.3@jar". They're causing me problems such that I can't build the project. I can't seem to figure out how they got there or where they're being used.

enter image description here

enter image description here

The error message I get when I build right now is:

"Error:Error: xpp3 defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]"

The error message is good except that it doesn't tell me who's using this lib in the first place.

The question

Is there an easy way to find out where they're being used in the project? Or even a way that it's easy but doesn't require looking at every file? It's a multi module project with lots of files. If I could delete them this would tell me but there's no delete option.

This could be something really simple that I'm overlooking. Any help appreciated. Happy to add more info as requested.

What I've tried

I've tried to "Analyze Dependencies" but it doesn't show me any references that I can see.

Update: I forgot to mention that I've also tried ./gradlew app:dependencies but it only tells me that my project depends on these libraries. I already know this. Is there a way to get some more specific information so I can remove the libraries?

Update 2: The accepted answer does work but I needed to redirect console output.

Android Developer
  • 559
  • 1
  • 5
  • 17
Michael Vescovo
  • 3,741
  • 4
  • 32
  • 45
  • @cricket_007 the "duplicate" doesn't actually answer my question. I know these things are dependencies but where specifically are they coming from and how can I remove them? – Michael Vescovo Dec 04 '17 at 00:10
  • Ok I've solved the problem but the solution was just luck (by chance I found a dependency that wasn't used that was causing the problem). The supposed "duplicate" unfortunately didn't help but there's no way to mark it as not a duplicate. – Michael Vescovo Dec 04 '17 at 01:12
  • Removing a library can be found in different answers. You ask how to find which libraries are part of others, and that's what the duplicate is for. This shows you the artifactId and groupId, from which your can explicitly exclude from the compiled ones in your project – OneCricketeer Dec 04 '17 at 03:13
  • Also, you really don't need JAR files, do you? `compile 'stax:stax-api:1.0.1'` and `compile 'xpp3:xpp3:1.1.3.3'` should work – OneCricketeer Dec 04 '17 at 03:16
  • @cricket_007 no I ask how to find which files (specifically) depend on a library, not which libraries an entire project depends on. The question is unanswered. – Michael Vescovo Dec 04 '17 at 03:16
  • I'm not using those libraries in my dependencies. That's the whole point! No where in my code to I reference them directly. The screenshot is there to help show that I'm referring to the "external libraries" view. The one that gets generated automatically. – Michael Vescovo Dec 04 '17 at 03:18
  • You have a library that *is using them transitively*. Please add the output of the dependency command to the question – OneCricketeer Dec 04 '17 at 03:19
  • I put the lib back to try and get the output but now it's showing even less output when I run the gradle task. If I run via the terminal the output is cut off so I can't scroll up high enough to see it. Couldn't find how to get more output but haven't looked for very long and it's a different question. I'll try to update the question later when I work out how to do that but need to work on something else now. (who knows maybe it includes the answer). – Michael Vescovo Dec 04 '17 at 03:35
  • 1
    If the output is too large for a terminal, redirect to a file. `./gradlew app:dependencies > dependencies.txt` – OneCricketeer Dec 04 '17 at 04:34
  • 1
    ok thanks for the tip. After analysing the results I couldn't see any direct references to the library I added back in. However I think had I not known about this library and followed this tree I would also have solved the issue. So yes I will say now more confidently that it is indeed a duplicate. Thanks for your help! Not sure why the normal gradle task didn't output all that data - when double clicking the task under tasks->help->dependencies. – Michael Vescovo Dec 04 '17 at 05:06

2 Answers2

11
gradle app:dependencies

It will show you the dependencies tree of your project

At this link it is explained quite well about the command and how to use it.

Use this to redirect console output if it's clipped:

./gradlew app:dependencies > dependencies.txt
Michael Vescovo
  • 3,741
  • 4
  • 32
  • 45
Roberto Martucci
  • 1,237
  • 1
  • 13
  • 21
0

Project can be explored in "Project-tool-window" to have a look at the used external libraries which are not visible in "Android tool Window". https://www.jetbrains.com/help/idea/project-tool-window.html That way I solve my problem. Hope it help.enter image description here

Android Developer
  • 559
  • 1
  • 5
  • 17