Google Firabase身份验证例外与电子邮件

时间:2018-05-30 09:11:04

标签: android firebase firebase-authentication

我正在为Android编写应用程序。我太初学了。我复制并粘贴了一个样本到我的项目中。我想进行身份验证。但它给了我一个连接的例外。我创建了一个firebase。我连接到我的firebase服务器。但仍有一个例外。我点击我的按钮,结果总是返回我。同样的异常结果。这是我的代码,布局和图片:enter image description here enter image description here 我的布局:

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress"
    android:layout_marginTop="10dp"

    android:id="@+id/uyeEmail" />

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textPassword"
    android:ems="10"
    android:layout_marginTop="10dp"
    android:id="@+id/uyeParola"
    />


<Button
    android:text="Üye Ol!"
    android:layout_width="100dp"
    android:layout_height="50dp"
    android:layout_marginTop="50dp"

    android:id="@+id/yeniUyeButton"
  />


<Button
    android:text="Zaten üye misin?"
    android:layout_width="200dp"
    android:layout_height="wrap_content"

    android:id="@+id/uyeGirisButton"

    android:layout_marginBottom="10dp"
    />

我的代码:

  auth = FirebaseAuth.getInstance();
        uyeParola = (EditText)findViewById(R.id.uyeParola);
        uyeEmail = (EditText)findViewById(R.id.uyeEmail);

        uyeGirisButton = (Button)findViewById(R.id.uyeGirisButton);
        uyeGirisButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });



        yeniUyeButton = (Button)findViewById(R.id.yeniUyeButton);
        yeniUyeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String email = uyeEmail.getText().toString();
                String parola = uyeParola.getText().toString();

                if(TextUtils.isEmpty(email)){
                    Toast.makeText(getApplicationContext(),"Lütfen emailinizi giriniz",Toast.LENGTH_SHORT).show();
                    return;
                }
                if(TextUtils.isEmpty(parola)){
                    Toast.makeText(getApplicationContext(),"Lütfen parolanızı giriniz",Toast.LENGTH_SHORT).show();
                }
                if (parola.length()<6){
                    Toast.makeText(getApplicationContext(),"Parola en az 6 haneli olmalıdır",Toast.LENGTH_SHORT).show();
                }

                //FirebaseAuth ile email,parola parametrelerini kullanarak yeni bir kullanıcı oluşturuyoruz.
                auth.createUserWithEmailAndPassword(email,parola)
                        .addOnCompleteListener(giris.this, new OnCompleteListener<AuthResult>() {
                            @Override
                            public void onComplete(@NonNull Task<AuthResult> task) {

                                //İşlem başarısız olursa kullanıcıya bir Toast mesajıyla bildiriyoruz.
                                if (!task.isSuccessful()) {
                                    Toast.makeText(giris.this, "Exception... Sorry :(",
                                            Toast.LENGTH_SHORT).show();
                                }

                                //İşlem başarılı olduğu takdir de giriş yapılıp MainActivity e yönlendiriyoruz.
                                else {
                                    startActivity(new Intent(giris.this, MainActivity.class));
                                    finish();
                                }

                            }
                        });
            }
        });

我的许可:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>[enter image description here][1]

1 个答案:

答案 0 :(得分:0)

整整3天,我都在搜索我的问题。我终于找到了答案。我必须将这段代码粘贴到我的build.grandle上。如果我不这样做,我总会遇到这些问题。

这是我复制的链接:

Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation'

代码和平:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

        classpath 'com.google.gms:google-services:3.2.0'
    }
}
相关问题