Skip to content

java.lang.NoSuchMethodError exception, caused by dependency conflict with Guava in truth/extensions/liteproto #473

Closed
@LeoAugust19

Description

@LeoAugust19

Hi, dependency conlict issue exists in truth/extensions/liteproto. As shown in the following dependency tree, this project directly depends on com.google.guava:guava:jar:23.6, and transitively depends on com.google.guava:guava:jar:25.1, based on Maven's loading mechanism, the old version wins the newer one.

Dependency tree:
com.google.truth.extensions:truth-liteproto-extension:jar:0.41
+- com.google.truth:truth:jar:0.41:compile
| +- (com.google.guava:guava:jar:25.1-android:compile - omitted for conflict with 23.6-android)
+- com.google.guava:guava:jar:23.6-android:compile

However, method com.google.common.base.Strings.lenientFormat(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String is referenced by the host project and only defined in guava:jar:25.1, which causes the java.lang.NoSuchMethodError exception.

When executing the following test case, we got the stack trace:

Test case:

LiteProtoTruth.assertThat(UnknownFieldSet.getDefaultInstance()).isEqualTo(new Object());

Stack trace:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Strings.lenientFormat(Ljava/lang/String;

[Ljava/lang/Object;)Ljava/lang/String;
at com.google.common.truth.Subject.failWithRawMessage(Subject.java:1043)
at com.google.common.truth.extensions.proto.LiteProtoSubject.isEqualTo(LiteProtoSubject.java:106)
at com.google.common.truth.extensions.proto.Test.main(Test.java:11)

The solution is to update com.google.guava:guava:jar:23.6 to 25.1 to make the version consistent.

Hope this report can help you. Thanks! ^_^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions