0

I have spent around 1 day learning the features of Admin SDK and found out that that API will help me a lot for managing users in the database but when I added to my project Build.Gradle file. it shows this error:

"could not find method implementation() for arguments [com.google.firebase:firebase-admin:6.6.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler."

screenshot of the error

Alex
  • 77
  • 1
  • 9
  • 1
    You put that in the wrong Gradle file – OneCricketeer Dec 14 '18 at 01:38
  • 1
    Also, you can't use the Admin SDK directly in an Android app. It's for use in backend programs. – Doug Stevenson Dec 14 '18 at 01:45
  • 1
    so this dependency should be placed in the backend programmes like I am using a firebase database as a backend service. How I can integrate this API with my project – Alex Dec 14 '18 at 02:05
  • One way to do that would be by exposing the Admin SDK from Cloud Functions, as shown here: https://firebase.google.com/docs/functions/callable. Be sure to think about authorization though. Calling this administrative functionality typically should only be possible for certain authorized users (i.e. "admins"). – Frank van Puffelen Dec 14 '18 at 04:43
  • @FrankvanPuffelen what is about this dependence "implementation 'com.google.firebase:firebase-admin:6.6.0'" where i should place in order to use its functionalities such as Manage Users through using CreateRequest request = new CreateRequest() .setEmail("user@example.com") .setEmailVerified(false) .setPassword("secretPassword") .setPhoneNumber("+11234567890") .setDisplayName("John Doe") .setPhotoUrl("http://www.example.com/12345678/photo.png") .setDisabled(false); – Alex Dec 14 '18 at 05:03
  • I have no idea what that means Alex. But in the screenshot you shared, it looks like you're trying to add the Admin SDK to an Android app. As [Bilger answered on your previous question](https://stackoverflow.com/questions/53760086/how-to-add-admin-sdk-api-to-android-project), you will need to add the Admin SDK to Cloud Functions. If you're new to Cloud Functions, I recommend first taking a codelab for it: https://codelabs.developers.google.com/codelabs/firebase-cloud-functions/ – Frank van Puffelen Dec 14 '18 at 05:17

1 Answers1

0

put your implementation xxx to your app level build.gradle, NOT the TOP Level one.

E.g. under app/build.gradle

dependencies {
    // here 
    implementation 'com.google.firebase:firebase-admin:6.6.0'
    implementation ('com.google.firebase:firebase-messaging:9.6.1'){
        exclude module: 'firebase-common'
    }
    implementation ('com.google.firebase:firebase-auth:9.6.1'){
        exclude module: 'firebase-common'
    }
    implementation ('com.google.firebase:firebase-database:9.6.1'){
        exclude module: 'firebase-common'
    }
    implementation ('com.firebase:firebase-client-android:2.5.0'){
        exclude module: 'firebase-common'
    }

}
shizhen
  • 12,251
  • 9
  • 52
  • 88
  • According to firebase Admin SDK that dependency should be used in the Build. Gradle , I have tried to use it in the app level but the dependencies conflict with others. – Alex Dec 14 '18 at 02:12
  • use this `exclude module: 'firebase-common'` for the conflict – shizhen Dec 14 '18 at 03:21
  • But in their documentation, they said that dependence should be used in the back-end service which I am using Firebase-database as a back-end service and I do not understand how I can place it in the back-end service. – Alex Dec 14 '18 at 05:00