Ad

How To Handle Gradle Dependencies That Are Apparently Overwriting Each Other

I am developing an application using google firebase (authentification and cloud firestore). Following the documentation I am supposed to add the following dependency to my app level build.gradle file in order to access the cloud firestore database

implement 'com.google.firebase:firebase-admin:6.8.1'

However, this approach produces the following error when compiling:

"Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. - auto-value-1.4.jar (com.google.auto.value:auto-value:1.4) Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future. See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details."

I have tried fixing the problem, as described in the linked website in the error message, by replacing the dependency with:

compileOnly 'com.google.firebase:firebase-admin:6.8.1'
annotationProcessor 'com.google.auto.value:auto-value:1.4'

This removes the old error but causes another problem which I have not been able to fix. Adding the dependency 'com.google.firebase:firebase-admin:6.8.1' causes some methods from the 'com.google.firebase:firebase-auth:17.0.0' dependency not to work anymore.

"error: cannot find symbol method getCurrentUser()
error: cannot find symbol method signInWithCredential(AuthCredential)"

My first idea was that the admin dependency includes some of the same classes that the auth one has. However, I do not really know too much about the gradle behavior in those kind of situations and how to fix this.

Below are my dependencies from the build.gradle file

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.facebook.android:facebook-login:[5,6)'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.9'      
    compileOnly 'com.google.firebase:firebase-admin:6.8.1'
    annotationProcessor 'com.google.auto.value:auto-value:1.4'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Ad

Answer

The firebase-admin dependency is not meant to be used in client apps. It's for use with server code. It may conflict with the Firebase client SDKs that are meant for Android. If you want to use firebase-admin, you will need a backend component to your app and invoke it there.

Ad
source: stackoverflow.com
Ad