ada
ada

Reputation: 11

Firebase auth error android studio

I try to check out a project we are working on and when i try to run it but i'm getting the follow error while the my other colleague run the project perfect.

05-11 20:33:09.487 9823-9823/groupass.amc.chatroom E/AndroidRuntime: FATAL EXCEPTION: main
                                                                 Process: groupass.amc.chatroom, PID: 9823
                                                                 java.lang.NoSuchMethodError: No direct method <init>(Lcom/google/firebase/FirebaseApp;)V in class Lcom/google/android/gms/internal/zzbne; or its super classes (declaration of 'com.google.android.gms.internal.zzbne' appears in /data/app/groupass.amc.chatroom-2/split_lib_dependencies_apk.apk:classes5.dex)
                                                                     at com.google.firebase.auth.FirebaseAuth.zzd(Unknown Source)
                                                                     at com.google.firebase.auth.FirebaseAuth.zzc(Unknown Source)
                                                                     at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
                                                                     at groupass.amc.chatroom.auth.LoginActivity.onCreate(LoginActivity.java:36)
                                                                     at android.app.Activity.performCreate(Activity.java:6662)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                                                                     at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                     at android.os.Looper.loop(Looper.java:154)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Here, is the log in activity.java file:

package groupass.amc.chatroom.auth;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;


import groupass.amc.chatroom.MainActivity;
import groupass.amc.chatroom.R;

public class LoginActivity extends AppCompatActivity {

private EditText inputEmail, inputPassword;
private FirebaseAuth auth;
private ProgressBar progressBar;
private Button btnSignup, btnLogin, btnReset;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //Get Firebase auth instance
    auth = FirebaseAuth.getInstance();

    if (auth.getCurrentUser() != null) {
        startActivity(new Intent(LoginActivity.this, MainActivity.class));
        finish();
    }

    // set the view now
    setContentView(R.layout.activity_login);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    inputEmail = (EditText) findViewById(R.id.email);
    inputPassword = (EditText) findViewById(R.id.password);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    btnSignup = (Button) findViewById(R.id.btn_signup);
    btnLogin = (Button) findViewById(R.id.btn_login);
    btnReset = (Button) findViewById(R.id.btn_reset_password);

    //Get Firebase auth instance


    btnSignup.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(LoginActivity.this, SignupActivity.class));
        }
    });


    btnLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String email = inputEmail.getText().toString();
            final String password = inputPassword.getText().toString();

            if (TextUtils.isEmpty(email)) {
                Toast.makeText(getApplicationContext(), "Enter email address!", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(password)) {
                Toast.makeText(getApplicationContext(), "Enter password!", Toast.LENGTH_SHORT).show();
                return;
            }

            progressBar.setVisibility(View.VISIBLE);

            //authenticate user
            auth.signInWithEmailAndPassword(email, password)
                    .addOnCompleteListener(LoginActivity.this, new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {
                            // If sign in fails, display a message to the user. If sign in succeeds
                            // the auth state listener will be notified and logic to handle the
                            // signed in user can be handled in the listener.
                            progressBar.setVisibility(View.GONE);
                            if (!task.isSuccessful()) {
                                // there was an error
                                if (password.length() < 6) {
                                    inputPassword.setError(getString(R.string.minimum_password));
                                } else {
                                    Toast.makeText(LoginActivity.this, getString(R.string.auth_failed), Toast.LENGTH_LONG).show();
                                }
                            } else {
                                Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                                startActivity(intent);
                                finish();
                            }
                        }
                    });
        }
    });
}
}

I think that is authentication problem but I can't find something. I can't find answers with similar problem.

Upvotes: 1

Views: 1450

Answers (1)

Amit Sharma
Amit Sharma

Reputation: 645

Update your fire base in girdle file. Some time it wont download properly due to network connection. Lets build it again.

Upvotes: 1

Related Questions