Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.yaml:snakeyaml dependency is giving an error because 'android' classifier #327

Open
yolave opened this issue Oct 30, 2018 · 26 comments
Open

Comments

@yolave
Copy link

yolave commented Oct 30, 2018

In the pom.xml file, the declared dependency for org.yaml:snakeyaml has the 'android' classifier so, when a project compiles, it gets an error because the name of the library who is tried to be downloaded (from jcenter: https://jcenter.bintray.com/org/yaml/snakeyaml/1.17/snakeyaml-1.17-android.jar, from maven central: https://repo1.maven.org/maven2/org/yaml/snakeyaml/1.17/snakeyaml-1.17-android.jar). My project is a normal java one (not android) and i'm using Gradle instead Maven.

  • is it possible to remove this classifier if it is not really used?
  • if the request above can't be done, do you know any method to fix this?

Thank you!

@Outpox
Copy link

Outpox commented Nov 22, 2018

Same issue here :-/

@vijayanandnandam
Copy link

I have also encountered this issue. please fix. I am using this library in a spring boot project

Task :compileTestJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':testCompileClasspath'.
> Could not find snakeyaml-android.jar (org.yaml:snakeyaml:1.17).
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/yaml/snakeyaml/1.17/snakeyaml-1.17-android.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings

@yolave
Copy link
Author

yolave commented Nov 28, 2018

For all those reporting the same issue, i did configure my project to avoid this problem.
Simply, go to your build.gradle file, exclude the problematic dependency and then add it again:

implementation ('com.github.javafaker:javafaker:0.14') { exclude module: 'org.yaml' }
implementation group: 'org.yaml', name: 'snakeyaml', version: '1.17'

@codingricky
Copy link
Contributor

Which version of java-faker are you using? The latest version uses snake-yaml 1.20 which is resolvable.

@yolave
Copy link
Author

yolave commented Dec 8, 2018

In my case, i'm using the version 0.14. The POM file for this release has the snake-yaml 1.19 with the classifier "android", so Gradle or Maven can't find the library in any remote repository.

Here's an extract from the POM file for the release version 0.14 of Java-Faker:

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.19</version>
<classifier>android</classifier>
</dependency>

@vijayanandnandam
Copy link

For all those reporting the same issue, i did configure my project to avoid this problem.
Simply, go to your build.gradle file, exclude the problematic dependency and then add it again:

implementation ('com.github.javafaker:javafaker:0.14') { exclude module: 'org.yaml' }
implementation group: 'org.yaml', name: 'snakeyaml', version: '1.17'

This works..

@codingricky
Copy link
Contributor

@yolave could you use the latest version 0.16 and see if you've get the same error?

Thanks

@yolave
Copy link
Author

yolave commented Dec 20, 2018

OK @codingricky , i've performed some tests over my project changing the library version. What i've found is there are two problems with the mentioned library above.

The first problem is with the org.yaml:snakeyaml:1.17 library. This library is used in other projects like Spring Boot (1.5.9-RELEASE) and Google Cloud Appengine Plugin (0.3.9) and they eventually replace the version defined by java-faker when build. When i run the gradle --dependencies command, i get this:

default - Configuration for default artifacts.
+--- com.github.javafaker:javafaker:0.16
| +--- org.apache.commons:commons-lang3:3.5 -> 3.7
| +--- org.yaml:snakeyaml:1.20 -> 1.17
| \--- com.github.mifmif:generex:1.0.2
| \--- dk.brics.automaton:automaton:1.11-8
\--- project :reelder-dom
\--- project :reelder-utils
\--- org.apache.commons:commons-lang3:3.7

Another library is overwriting the default version of the dependency used by java-faker (1.20 -> 1.17). I've tried to force to use the defined version of the library in java-faker's pom but with no success. Suggestions will be accepted to try to fix this.

The second problem is related to the library itself. where the classifier is defined in the project's pom file. As i posted above, the pom.xml for the java-faker project has the <classifier>android</classifier> tag, so, even if the first problem described above is fixed, when a project will compile, gradle would try to use/download the library snakeyaml-1.20-android.jar, which does not exist in any remote repository.

If you need any other test, drop me a comment and I'll try to help out.

@yolave
Copy link
Author

yolave commented Dec 20, 2018

UPDATE

I perform a new test and i found what is going on. My project is a spring boot type one, so i have in the root build.gradle file, the option to apply the spring boot plugin (apply plugin: 'org.springframework.boot') to all the subprojects. With this, if any sub project is using a specific library version used by others libraries, they will be overwritten by the defined by the spring boot plugin. This would be fixed forcing to use the defined version in the transient libraries, however, i have not had any luck with this.
By the way, the snakeyaml added the android classifier library to jcenter since the version 1.18, so any reference to a lower version will fail when try to download it. That's the reason why my project is trying to download the snakeyaml-1.17-android.jar and fails.

@dimalusa
Copy link

dimalusa commented Mar 3, 2019

Same issue ! :'(

@ArtRoman
Copy link

ArtRoman commented Mar 4, 2020

For all those reporting the same issue, i did configure my project to avoid this problem.
Simply, go to your build.gradle file, exclude the problematic dependency and then add it again:

implementation ('com.github.javafaker:javafaker:0.14') { exclude module: 'org.yaml' }
implementation group: 'org.yaml', name: 'snakeyaml', version: '1.17'

You should exclude library by artifact, not by group.
In my case correct line is { exclude module: 'snakeyaml' }

@Samyssmile
Copy link

Samyssmile commented Jul 3, 2020

This solved it for me

implementation ('com.github.javafaker:javafaker:1.0.2') { exclude module: 'org.yaml' }
implementation group: 'org.yaml', name: 'snakeyaml', version: '1.26'

But dirty workaround anyway.

@RockyMM
Copy link
Contributor

RockyMM commented Jul 22, 2020

@Samyssmile what you did should be solved with #470

@SonaliSammy
Copy link

This issue is fixed with version 0.18 of Javafaker

@vinz486
Copy link

vinz486 commented Nov 23, 2020

This issue is fixed with version 0.18 of Javafaker

I'm still having this issue with javafaker 1.0.2

@SonaliSammy
Copy link

This issue is fixed with version 0.18 of Javafaker

I'm still having this issue with javafaker 1.0.2

i checked with Javafaker 1.0.2 version after your message. I don't get issue in that version even. i was facing issue with javafaker 0.14. with Upgrade my problem got resolved. Javafaker 1.0.2 they use both snakyaml 1.2.3 and snakeyaml 1.2.3-android.

@vinz486
Copy link

vinz486 commented Nov 24, 2020 via email

@RockyMM
Copy link
Contributor

RockyMM commented Dec 31, 2020

@vinz486 , please make a sample project where your problem could be reproduced.

@saphemmy
Copy link

saphemmy commented Feb 15, 2021

This issue is fixed with version 0.18 of Javafaker

I'm still having this issue with javafaker 1.0.2

i checked with Javafaker 1.0.2 version after your message. I don't get issue in that version even. i was facing issue with javafaker 0.14. with Upgrade my problem got resolved. Javafaker 1.0.2 they use both snakyaml 1.2.3 and snakeyaml 1.2.3-android.

0.18 works Using maven

@Mahoney
Copy link

Mahoney commented Apr 6, 2022

I've suddenly got this issue because a different dependency brought in org.yaml:snakeyaml:1.30 transitively, and gradle's dependency resolution combines that with java-faker's android classifier to produce a dependency on org.yaml:snakeyaml:1.30-android - which doesn't exist:

> Could not find snakeyaml-1.30-android.jar (org.yaml:snakeyaml:1.30).
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/yaml/snakeyaml/1.30/snakeyaml-1.30-android.jar

I checked out this project and it builds fine if I remove <classifier>android</classifier> from the snakeyaml dependency.

@bodiam
Copy link

bodiam commented Apr 6, 2022

@Mahoney'm this has been fixed in Datafaker, an active clone of this repo with most of not all issues fixed.

@Mahoney
Copy link

Mahoney commented Apr 7, 2022

@bodiam thanks - I'll consider migrating to datafaker. net.datafaker:datafaker, presumably?

In the meantime, this works as a way to strip the android classifier:

configurations.all {
  resolutionStrategy.eachDependency { details ->
    if (details.requested.module.toString() == 'org.yaml:snakeyaml') {
      details.artifactSelection {
        it.selectArtifact(DependencyArtifact.DEFAULT_TYPE, null, null)
      }
    }
  }
}

@debop
Copy link

debop commented Apr 10, 2022

@Mahoney Thanks your suggestion. it works.

this is kotlin-dsl port

    configurations.all {
        resolutionStrategy.eachDependency {
            if(requested.module.toString() == "org.yaml:snakeyaml") {
                artifactSelection {
                    selectArtifact(DependencyArtifact.DEFAULT_TYPE, null, null)
                }
            }
        }
    }

@RyoSaeba06
Copy link

Hi there, I got the issue Could not find snakeyaml-1.30-android.jar (org.yaml:snakeyaml:1.30). Searched in the following locations: https://repo.maven.apache.org/maven2/org/yaml/snakeyaml/1.30/snakeyaml-1.30-android.jar with spring boot 2.7.1 but working well with spring boot 2.6.2

@bodiam
Copy link

bodiam commented Jun 29, 2022

@RyoSaeba06 this if a known issue. The recommendation is to use Datafaker.net, a maintained fork of this library

@pathiec92
Copy link

If you are using gradle-kotlin, use the below code to resolve this issue.

implementation("com.github.javafaker:javafaker:1.0.2"){ exclude ( "org.yaml") } implementation (group= "org.yaml", name= "snakeyaml", version= "2.0")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests