I am using Firebase MLKit in my app, like so FirebaseVision.getInstance().cloudImageLabeler
.
I am only using the cloud versions of it. But when I look at the apk, it includes large native libraries from Firebase, 10Mb in total for 4 architectures. This make up 80% of my app size. They are named libclassifier_jni.so
for each architecture.
Upon further inspection of the libraries extracted from the apk, using objdump -d
, I found these are related to on device image labelling. It has symbols like Java_com_google_android_libraries_vision_visionkit_recognition_classifier_NativeClassifier_initialize
.
I am sure that I am not using anything Firebase ML on device.
How can I remove these libraries and reduce the size of the apk?
The build is of type release and has proguard rules.
Edit:
Relevant dependencies:
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.google.firebase:firebase-ml-vision:23.0.0'
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:18.0.0'
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.google.firebase:firebase-functions:19.0.1'
It doesn't make a difference if I update to the latest.
What dependency did you include in your gradle file?
If you are seeing visionkit then you probably are including com.google.firebase:firebase-ml-vision-object-detection-model or an vision internal sdk by accident.
The only dependency you need for cloud image labeling is com.google.firebase:firebase-ml-vision