com.google.firebase.FirebaseException:发生内部错误

时间:2017-07-23 13:48:00

标签: java android firebase firebase-authentication

我正在尝试在android中注册ftrabase。我收到了一些错误。

错误说:

  

com.google.firebase.FirebaseException:发生内部错误。 [未配置访问权限。 Google Identity Toolkit API尚未用于项目''之前或它被禁用。访问https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=''启用它然后重试。如果您最近启用了此API,请等待几分钟,以便将操作传播到我们的系统并重试。

和这个

  

找不到com.google.firebase.auth的本地模块描述符类。

我在谷歌搜索错误但仍无法找到解决方案。我在等你的帮助。

Project build.gradle:

    classpath 'com.google.gms:google-services:3.1.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
    delete rootProject.buildDir
}

模块build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.android.nagchat"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-auth:10.2.4'
    compile 'com.google.android.gms:play-services:10.2.4'
    testCompile 'junit:junit:4.12'
}

和我的RegisterActivity.class

public class RegisterActivity extends AppCompatActivity {

    private TextInputLayout mDisplayName;
    private TextInputLayout mEmail;
    private TextInputLayout mPassword;
    private Button mCreateRegBtn;

    private FirebaseAuth mAuth;

    void init(){
        mDisplayName = (TextInputLayout)findViewById(R.id.reg_display_name);
        mEmail = (TextInputLayout)findViewById(R.id.reg_email);
        mPassword = (TextInputLayout)findViewById(R.id.reg_password);
        mCreateRegBtn = (Button)findViewById(R.id.btnRegCreate);

        mAuth = FirebaseAuth.getInstance();
    }

    void clickable(){
        mCreateRegBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String displayName = mDisplayName.getEditText().getText().toString();
                String email = mEmail.getEditText().getText().toString();
                String password = mPassword.getEditText().getText().toString();

                registerUser(displayName, email, password);
            }
        });
    }

    private void registerUser(String displayName, String email, String password) {
        mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {
                if(task.isSuccessful()){
                    Intent mainIntent = new Intent(RegisterActivity.this, MainActivity.class);
                    startActivity(mainIntent);
                    finish();
                }else {
                    Toast.makeText(RegisterActivity.this, "You got some error!", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        init();
        clickable();
    }
}

0 个答案:

没有答案