Firebase Admin Java API Issue

966 views
Skip to first unread message

Frank Kicenko

unread,
Mar 8, 2018, 8:36:08 AM3/8/18
to Firebase Google Group
While attempting to send a notification message to a device using the API, i'm getting the following error.

java.lang.NoSuchMethodError: com.google.common.primitives.Booleans.countTrue([Z)I
    at com.google.firebase.messaging.Message.<init>(Message.java:71)
    at com.google.firebase.messaging.Message.<init>(Message.java:39)
    at com.google.firebase.messaging.Message$Builder.build(Message.java:226)

Would seem that the Message class isn't including the Boolean class. Below is the sample code producing the error:
Message message = Message.builder()
            .setAndroidConfig(AndroidConfig.builder()
                .setTtl(3600 * 1000) // 1 hour in milliseconds
                .setPriority(AndroidConfig.Priority.HIGH)
                .setNotification(AndroidNotification.builder()
                    .setTitle("$GOOG up 1.43% on the day")
                    .setBody("$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.")
                    .setIcon("stock_ticker_update")
                    .setColor("#f45342")
                    .build())
                .build())
            .setTopic("industry-tech")
            .build();

Hiranya Jayathilaka

unread,
Mar 8, 2018, 1:09:00 PM3/8/18
to fireba...@googlegroups.com
If I were to guess, you have an old version of Guava installed in your runtime. The countTrue() method has been present since Guava 16.0. Admin SDK depends on Guava 20.0. You will have to inspect you dependency tree, find and exclude the old/incompatible guava version.


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/b7bf692d-f081-4da9-95dc-e4c00a147aa9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Hiranya Jayathilaka | Software Engineer | h...@google.com | 650-203-0128

Frank Kicenko

unread,
Mar 9, 2018, 1:33:41 PM3/9/18
to Firebase Google Group

I don't think so.... i've checked the versioning and opened the .jar... here is the .pom

<dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>24.0-jre</version>
        </dependency>

Hiranya Jayathilaka

unread,
Mar 9, 2018, 1:49:23 PM3/9/18
to fireba...@googlegroups.com
Your JVM is still picking up an older version of Guava. If it used v24.0, it wouldn't have had issues finding the countTrue() method: https://github.com/google/guava/blob/v24.0/guava/src/com/google/common/primitives/Booleans.java#L513

This happens often due to the way Maven dependency resolution works. Multiple incompatible artifacts with the same class/package ends up in the classpath, and the JVM arbitrarily binds to one of them. You should probably start by inspecting the "mvn dependency:tree" output.



For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages