firebase-admin-java
firebase-admin-java copied to clipboard
Library size with dependencies
The library with all dependencies is really big. I only want to use Firebase push notifications. Can I exclude any dependencies to reduce the size?
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
To add an additional point to this, in upgrading from com.google.firebase:firebase-admin 8.2.0 => 9.0.0, we have an increase in our jar size by 21.3MB. Background: Kotlin 1.7.10, server-side, not Android. @lahirumaramba I believe the only change this could've been related to is by updating the google cloud libraries bom / client api.
Is it safe to exclude google-cloud-firestore like this if I'm only interested in the Firebase push notifications?
implementation ("com.google.firebase:firebase-admin:9.0.0") {
exclude group: 'com.google.cloud', module: 'google-cloud-firestore'
}
@tananaev YMMV but I've excluded it and it seemed okay:
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>${firebaseAdmin.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-firestore</artifactId>
</exclusion>
</exclusions>
</dependency>
Yeah, I also tried it earlier and it works, but just wanted to confirm that there are no corner cases that will fail with class not found exceptions 🙂
Yup I would not say its officially supported but works 🤷♂️
Hey everyone, thanks for your patience on this. We have had some previous discussions on the library size (see #273), and as you mentioned above, using Maven exclusions is the correct way to remove the unwanted dependencies for your project. Gradle supports the same feature if that is your build tool. You should be able to exclude google-cloud-storage and google-cloud-firestore (assuming you don't use any of those APIs in your project) without any issue, plus some of the netty-* dependencies as well. See below for an example:
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>6.8.1</version>
<exclusions>
<exclusion>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-firestore</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
</exclusion>
</exclusions>
</dependency>
@lahirumaramba In 9.2.0 and 9.1.1, if I exclude google-cloud-storage it results in a java.lang.ClassNotFoundException: com.google.api.client.json.jackson2.JacksonFactory error because com.google.firebase.internal.ApiClientUtils uses it.
Could you please add an explicit dependency on com.google.api.client.json.jackson2?
Edit: it's actually com.google.http-client:google-http-client-jackson2, the api-client one is no longer available