I'm using phone authentication, it was working fine but after a couple of log in logout attempt its showing this error An internal error has occurred. [ MISSING_CLIENT_IDENTIFIER ] and getting no verification code. i've inserted all gradle files google json file and also enabled the authentication in firebase console. It was working fine on the beginning but now showing weired error, i can only enter with whitelist number now
my build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.devlearn.sohel.tkash"
minSdkVersion 21
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 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:animated-vector-drawable:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.github.ybq:Android-SpinKit:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:gridlayout-v7:27.1.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.firebaseui:firebase-ui-database:4.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.budiyev.android:circular-progress-bar:1.2.0'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.github.d-max:spots-dialog:0.7@aar'
implementation 'com.github.HotBitmapGG:RingProgressBar:V1.2.3'
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'
}
apply plugin: 'com.google.gms.google-services'
my logincode:
package com.devlearn.sohel.tkash;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.CountDownTimer;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.devlearn.sohel.tkash.Models.UserDetails;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseException;
import com.google.firebase.FirebaseTooManyRequestsException;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.PhoneAuthCredential;
import com.google.firebase.auth.PhoneAuthProvider;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.concurrent.TimeUnit;
import dmax.dialog.SpotsDialog;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
public class LoginActivity extends AppCompatActivity {
private EditText edtPhone;
private EditText edtName;
private TextView txtMessege;
private RelativeLayout rootlayout;
private ProgressBar progressBar;
private Button btnLogin;
private FirebaseAuth mAuth;
private DatabaseReference mDatabaseUsers;
public String phoneNumber;
public String userName;
private String mVerificationId;
public SpotsDialog waitingDialog;
private PhoneAuthProvider.ForceResendingToken mResendToken;
private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks;
// ctrl+o
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.SplashThme);
//before setcontentview
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Ubuntu.ttf")
.setFontAttrId(R.attr.fontPath)
.build());
setContentView(R.layout.activity_login);
edtPhone = (EditText)findViewById(R.id.edtphone);
edtName = findViewById(R.id.edtName);
btnLogin = (Button)findViewById(R.id.btnLogin);
txtMessege = (TextView)findViewById(R.id.txtMessege);
rootlayout = (RelativeLayout)findViewById(R.id.rootlayout);
mAuth = FirebaseAuth.getInstance();
mDatabaseUsers = FirebaseDatabase.getInstance().getReference().child("Users");
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// startActivity(new Intent(LoginActivity.this,MainActivity.class));
phoneNumber = edtPhone.getText().toString();
userName = edtName.getText().toString().trim();
if(TextUtils.isEmpty(phoneNumber))
{
edtPhone.setError("Incorrect phone number format");
requestFocus(edtPhone);
}
else if(TextUtils.isEmpty(userName))
{
edtName.setError("Please insert your name");
requestFocus(edtName);
}
else
{
phoneNumber = edtPhone.getText().toString();
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
signInWithPhoneAuthCredential(phoneAuthCredential);
}
@Override
public void onVerificationFailed(FirebaseException e) {
String error = e.getMessage();
Snackbar.make(rootlayout, "Error "+e, Snackbar.LENGTH_LONG)
.show();
Log.d("Error fire",error);
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// ...
String erro = e.getMessage();
Toast.makeText(LoginActivity.this, "error"+ erro, Toast.LENGTH_SHORT).show();
Log.d("Error fire",erro);
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// ...
String err = e.getMessage();
Toast.makeText(LoginActivity.this, "error"+ err, Toast.LENGTH_SHORT).show();
Log.d("Error fire",err);
}
}
@Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
// The SMS verification code has been sent to the provided phone number, we
// now need to ask the user to enter the code and then construct a credential
// by combining the code with a verification ID.
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
mResendToken = token;
// progressBar.setVisibility(View.INVISIBLE);
// ...
}
};
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber,
60,
TimeUnit.SECONDS,
LoginActivity.this,
mCallbacks
);
LoginUisngPhone();
}
}
});
}
private void LoginUisngPhone() {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("Verification");
// dialog.setMessage("Please provide verification Code");
LayoutInflater inflater = LayoutInflater.from(this);
View layout_verification = inflater.inflate(R.layout.layout_verification,null);
final EditText edtVerificationCode = layout_verification.findViewById(R.id.edtVerificationCode);
final TextView txtCountdown = layout_verification.findViewById(R.id.txtCountdown);
final ProgressBar progressBar = layout_verification.findViewById(R.id.progressbar);
CountDownTimer countDownTimer = new CountDownTimer(60000, 1000) {
public void onTick(long millisUntilFinished) {
txtCountdown.setText("Please provide Verificatin Code sec remaining: " + millisUntilFinished / 1000);
txtMessege.setTextColor(getResources().getColor(R.color.errorcolor));
txtMessege.setText("Please wait for "+ millisUntilFinished / 1000+" sec to try Again");
btnLogin.setEnabled(false);
edtName.setEnabled(false);
edtPhone.setEnabled(false);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…