1

I need to implement the google vision classes, but they conflict with my other firebase classes on the dependency of protobuf and grpc.

To sum up, firebase on my project manages users and their media uploads, which is where the vision api and safe search would come in to make sure the user does not upload anything that they are not supposed to.

I ended up with a gradle file that looks like this:

dependencies {
    implementation platform('com.google.cloud:libraries-bom:20.9.0')
    implementation ('com.google.cloud:google-cloud-vision')
    {
        exclude group: 'com.google.api.grpc'
        exclude group: 'com.google.protobuf'
    }
    implementation("com.google.guava:guava:30.1.1-android")
    implementation 'com.google.gms:google-services:4.3.8'
    implementation platform('com.google.firebase:firebase-bom:28.1.0')
    implementation 'com.google.firebase:firebase-firestore-ktx'
    implementation 'com.google.firebase:firebase-auth-ktx'
    implementation 'com.google.firebase:firebase-database-ktx'
    implementation 'com.google.firebase:firebase-storage-ktx'
    implementation 'androidx.preference:preference-ktx:1.1.1'
    implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'com.github.MikeOrtiz:TouchImageView:3.0.3'
    implementation 'id.zelory:compressor:3.0.0'
    implementation 'com.github.chrisbanes:PhotoView:2.3.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2'
    testImplementation 'junit:junit:4.13.2'
    implementation 'com.google.android.gms:play-services-vision:20.1.3'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'cn.aigestudio.wheelpicker:WheelPicker:1.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    implementation 'com.github.bumptech.glide:annotations:4.11.0'
    annotationProcessor 'androidx.annotation:annotation:1.2.0'
    implementation "com.google.android.material:material:1.5.0-alpha01"
    implementation 'com.synnapps:carouselview:0.1.5'
    implementation "androidx.databinding:databinding-compiler-common:7.0.0"
    implementation 'org.tensorflow:tensorflow-lite:2.5.0'
    implementation 'org.tensorflow:tensorflow-lite-support:0.1.0'
}

While the exclude helps with the duplicate problems, my class that uses the vision api breaks with unresolved references, specifically on these:

import com.google.cloud.vision.v1.AnnotateImageRequest
import com.google.cloud.vision.v1.Feature
import com.google.cloud.vision.v1.Image

These imports if I remember correctly are related to the protobuf class, but I may be mistaken. I'm kinda lost here, what can I do?

Edit.:

Tried the answer from this post here, and after adding:

{
    exclude module: 'protolite-well-known-types'
    exclude module: 'protobuf-javalite'
    exclude module: 'protobuf-java'
    exclude module: 'protobuf-java-util'
}

To the firestore implementation, it resolves the classes problems from the vision API, but breaks firebase, and the app won't launch. I will try different ways to use the safe search, maybe build my own model. From what I've researched, seems the google vision api is directed more to other uses than mobile, thus using a different version of protobuf, which conflicts with firebase.

Since this does not seem like something I can resolve on my own, and many other people have the same/similar problems when trying to implement both of them, I wish you luck in the future, the question stays here if me or someone else figures out a way to solve this NOT by making my own jar implementations, which is very unproductive.

Luis
  • 123
  • 1
  • 3
  • 18

0 Answers0