android studio firebase firestore : Permission_denied - android

This is my first time using firebase with android studio and specifically firebase firestore . I have a form where I submit my data and try to insert it in my firestore db . When I fill the form and submit I get this message from W/Firestore in my console :
Which just denies permission to my firestore db . No error hits in my app as if nothing happened and my document is not inserted in the firestore db .
My code to insert doc :
mFireStore = FirebaseFirestore.getInstance();
HashMap<String,String> data = new HashMap<>();
data.put("name", name.getText().toString());
data.put("surname", surname.getText().toString());
data.put("email", email.getText().toString());
data.put("amka", amka.getText().toString());
data.put("phone", phone.getText().toString());
mFireStore.collection("people").add(data).addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
#Override
public void onSuccess(DocumentReference documentReference) {
Toast.makeText(root.getContext(),"User added" , Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull #NotNull Exception e) {
Toast.makeText(root.getContext(),e.getMessage() , Toast.LENGTH_SHORT).show();
}
});
My build.gradle on project level :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath 'com.google.gms:google-services:4.3.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My build.gradle module in the app level
apply plugin:'com.android.application'
apply plugin:'com.google.gms.google-services'
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.covid19gate"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation platform('com.google.firebase:firebase-bom:28.1.0')
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.yarolegovich:discrete-scrollview:1.5.1'
implementation("com.squareup.okhttp3:logging-interceptor:4.9.1")
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
And lastly the rules in my firestore db :
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if
request.time < timestamp.date(2021, 7, 8);
}
}
}
I would appreciate your help .

Related

How to properly implement MapBox SDK to Android Studio Project?

I am trying to implement MapBox SDK to my Android Application. I followed the official documentation but I am getting this error.
Unable to resolve dependency for
':app#debugUnitTest/compileClasspath': Could not resolve
com.mapbox.maps:android:10.6.1.
I have tried following the legacy documentation, but still no luck. I would like to ask if there are any other ways to implement the SDK or did I miss something. TYIA.
Here are my gradle scripts:
build.gradle (Project Level)
buildscript {
ext.kotlin_version = "1.5.31"
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins
{
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
}
allprojects {
final def var = repositories
{
google()
mavenCentral()
maven { url 'https://esri.jfrog.io/artifactory/arcgis' }
maven { url 'https://olympus.esri.com/artifactory/arcgisruntime-repo/' }
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = "mapbox"
// Use the secret token you stored in gradle.properties as the password
password = MAPBOX_DOWNLOADS_TOKEN
}
}
}
var
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty("dependencies"))
{
dependencies {
implementation "androidx.appcompat:appcompat:1.4.1"
implementation "com.google.android.material:material:1.5.0"
implementation "com.esri.arcgisruntime:arcgis-android:$arcgisVersion"
implementation "androidx.multidex:multidex:2.0.1"
}
}
project.android {
defaultConfig {
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}
}
}
task clean(type: Delete)
{
delete rootProject.buildDir
}
build.gradle (Module level)
plugins
{
id 'com.android.application'
id 'com.google.gms.google-services'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id 'kotlin-android'
}
ext {
arcgisVersion = '100.13.0'
}
android
{
compileSdk 32
defaultConfig
{
applicationId "com.example.project1"
minSdk 26
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes
{
release
{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions
{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures
{
viewBinding true
}
}
dependencies
{
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.navigation:navigation-fragment:2.4.1'
implementation 'androidx.navigation:navigation-ui:2.4.1'
implementation 'com.android.volley:volley:1.2.1'
implementation 'com.google.firebase:firebase-messaging:21.1.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.gms:google-services:3.0.0'
implementation "androidx.appcompat:appcompat"
implementation "com.google.android.material:material"
implementation "com.esri.arcgisruntime:arcgis-android"
implementation "androidx.multidex:multidex"
implementation 'com.google.android.libraries.places:places:2.6.0'
implementation 'com.mapbox.maps:android:10.6.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
settings.gradle
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
rootProject.name = "proect1"
include ':app'

Unable to resolve Mapbox dependencies

I have been trying to integrate some on new features from Mapbox into my app but gradle is. unable to resolve the. newly added dependencies.
these. are. the dependencies that are not getting resolved
implementation 'com.mapbox.maps:android:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-annotation:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-locationcomponent:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-gestures:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-compass:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-animation:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-scalebar:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-logo:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-attribution:10.0.0-rc.8'
this is my. build.gradle file app level
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.a3dmapbox"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures{
dataBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Mapbox
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.0'
implementation "com.gorisse.thomas.sceneform:sceneform:1.20.1"
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:5.6.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-building-v9:0.7.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.11.0'
implementation("com.google.android.gms:play-services-location:18.0.0")
implementation 'com.mapbox.maps:android:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-annotation:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-locationcomponent:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-gestures:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-compass:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-animation:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-scalebar:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-logo:10.0.0-rc.8'
implementation 'com.mapbox.plugin:maps-attribution:10.0.0-rc.8'
}
this is my. project. level build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = 'mapbox'
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN']
}
}
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have configured the download token mapboxsdk is downloaded perfectly only the. newly added dependencies are making the issue
They won't resolve because you are using old references, chamge them to the new sdk implementations. For example for anotations:
implementation
'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
Reference
https://docs.mapbox.com/android/plugins/guides/annotation/
The issue here was that I was not specifying the repositories for all projects, in my build.gradle project level it should be like this
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
}
}
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = 'mapbox'
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN']
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Unable to write in firebase realtime database with Singapore asia-southeast1 as location

this is my build.gradel project file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
compose_version = '1.0.1'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
this is build.gradel module code
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.ehika.grp.myapplication1"
minSdk 23
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
useIR = true
}
buildFeatures {
compose true
viewBinding true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.1.0-alpha03"
kotlinCompilerVersion '1.5.21'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
apply plugin : "kotlin-android"
apply plugin : "kotlin-android-extensions"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
//Firebase
implementation platform('com.google.firebase:firebase-bom:28.4.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.android.gms:play-services-auth:19.2.0'
implementation 'com.google.firebase:firebase-auth-ktx:20.0.4'
implementation 'com.google.firebase:firebase-database-ktx'
}
this is my code to write data in realtime database
val currentUserID = FirebaseAuth.getInstance().currentUser!!.uid
val usersRef: DatabaseReference = FirebaseDatabase.getInstance().reference.child("Users")
val userMap = HashMap<String, Any>()
userMap["uid"] = currentUserID
usersRef.child(currentUserID).setValue(userMap)
.addOnCompleteListener{ task ->
if (task.isSuccessful){
Toast.makeText(baseContext, "Data stored successful.",
Toast.LENGTH_SHORT).show()
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
finish()
} else {
Toast.makeText(baseContext, "data not stored.",
Toast.LENGTH_SHORT).show()
}
}
i have tried changing from classpath 'com.google.gms:google-services:4.3.10'
to classpath 'com.google.gms:google-services:4.3.8' but it didn't workout for me.
these are my realtime database rules
{
"rules": {
"users": {
".read": true,
".write": true
}
}
}
In order to write some data into the Firebase Realtime Database, you need to use DatabaseReference#setValue(Object value). In code should look like this:
val database = Firebase.database
val myRef = database.getReference("message")
myRef.setValue("Hello, World!")
You might also attach a complete listener to see the result of the write operation.
Edit:
In order to use the following reference:
val usersRef: DatabaseReference = FirebaseDatabase.getInstance().reference.child("Users")
You need to create rules to allow access. Since you are using "users" instead of "Users":
{
"rules": {
"users": {
".read": true,
".write": true
}
}
}
Firebase servers will reject the write. So please use the following rules:
{
"rules": {
"Users": { //Use capital letter U
".read": true,
".write": true
}
}
}
Edit2:
Final change. Adding the URL location of the database fixed the problem.
getInstance() doesn't work with other location than us-central1 in Realtime Database

Unresolved refrence: requireLensFacing | Android Studio

I am getting 'Unresolved reference: requireLensFacing' for CameraSelector.Builder.requireLensFacing(lensFacing).build()
I have added camera core dependencies and I can actually open up the CameraSelector class and find the 'requireLensFacing' method inside it. But I just can't use it.
Here is my app gradle:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-android-extensions'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.devtyagi.facemaskdetector"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures{
mlModelBinding true
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
implementation 'com.google.android.material:material:1.2.1'
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
implementation "androidx.camera:camera-view:1.0.0-alpha20"
implementation "androidx.camera:camera-extensions:1.0.0-alpha20"
implementation "org.tensorflow:tensorflow-lite-metadata:${tflite}"
implementation "org.tensorflow:tensorflow-lite-gpu:2.2.0"
implementation 'org.tensorflow:tensorflow-lite-support:0.1.0-rc1'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
And here is my Project Level gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.21"
ext.tflite = "0.1.0-rc1"
ext.camerax_version = "1.0.0-rc01"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is the error:
Screenshot
How do I resolve this issue?
Thank You
You should use it like this val cameraSelector = CameraSelector.Builder().requireLensFacing(lensFacing).build()
you are using Builder replace it with Builder()

Unable to authenticate with Firebase

I am trying to sign in to Firebase on an emulator using credentials I added via the console.
Here is the code:
val auth = FirebaseAuth.getInstance()
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// ...
} else {
// ...
}
}
The OnCompleteListener callback is never triggered.
I have followed the guidelines from the Firebase documentation
google-services json file
Project dependencies
App dependencies
Enabled email/password sign in method
Any idea what I am doing wrong?
Gradle file - project:
buildscript {
ext.kotlin_version = '1.2.60'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle file - app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "..."
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
Is your email or password are valid?
You can add 'addOnFailureListener' to see what really happened.
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// ...
} else {
// ...
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(context, e.getMessage(),Toast.LENGTH_SHORT).show();
}
});
Try to add the following dependency in the build.gradle file:-
implementation 'com.google.firebase:firebase-core:16.0.1'
And I also recommend you to use the latest firebase dependencies.
I solved the issue by
Adding a new emulator
Enabling Identity Toolkit API in developer console (error visible in logcat on new emulator only)
This solution may be helpful for those of you who are using an emulator and have tried all the suggested answers...

Categories

Resources