Android 无法使用Firebase身份验证添加Firebase数据库

Android 无法使用Firebase身份验证添加Firebase数据库,android,firebase,firebase-realtime-database,firebase-authentication,firebaseui,Android,Firebase,Firebase Realtime Database,Firebase Authentication,Firebaseui,我正在尝试编写一个同时使用FirebaseAuth和Firebase实时数据库的程序。当我尝试在没有数据库的情况下运行程序时,它运行得很好,但是当我尝试包含数据库时,没有任何效果。我看到了这个错误: java.lang.NoSuchMethodError: No direct method <init>(Landroid/content/Context;Lcom/google/android/gms/internal/zzbma$zza;)V in class Lcom/google

我正在尝试编写一个同时使用FirebaseAuth和Firebase实时数据库的程序。当我尝试在没有数据库的情况下运行程序时,它运行得很好,但是当我尝试包含数据库时,没有任何效果。我看到了这个错误:

java.lang.NoSuchMethodError: No direct method <init>(Landroid/content/Context;Lcom/google/android/gms/internal/zzbma$zza;)V in class Lcom/google/android/gms/internal/zzbls; or its super classes (declaration of 'com.google.android.gms.internal.zzbls' appears in /data/app/com.dezlum.www.appforbank-2/split_lib_dependencies_apk.apk:classes12.dex)
                                                     at com.google.android.gms.internal.zzbma.zza(Unknown Source)
                                                     at com.google.firebase.auth.FirebaseAuth.zzb(Unknown Source)
                                                     at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
                                                     at com.google.android.gms.internal.zzbne.<init>(Unknown Source)
                                                     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 com.dezlum.www.appforbank.MainActivity.onCreate(MainActivity.java:50)
                                                     at android.app.Activity.performCreate(Activity.java:6317)
                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2543)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2682)
                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1512)
                                                     at android.os.Handler.dispatchMessage(Handler.java:111)
                                                     at android.os.Looper.loop(Looper.java:207)
                                                     at android.app.ActivityThread.main(ActivityThread.java:5811)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681)
当我从我的应用程序中删除依赖项和Firebase数据库时,它开始正常工作

这就是我的主要活动:-

package com.dezlum.www.appforbank;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.firebase.ui.auth.AuthUI;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;


import java.util.Arrays;

public class MainActivity extends AppCompatActivity {

private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
private String mUsername;
private static final String TAG = "MainActivity";
FirebaseUser user;
public static final String ANONYMOUS = "anonymous";
public static final int DEFAULT_MSG_LENGTH_LIMIT = 1000;
public static final int RC_SIGN_IN = 1;
public TextView chechker;
private Button signout;
SharedPreferences preferences;


 private FirebaseDatabase mFirebaseDatabase;
    private DatabaseReference mMessagesDatabaseReference;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mUsername = ANONYMOUS;
    preferences = getSharedPreferences("text",0);
    chechker = (TextView) findViewById(R.id.textview1);
    mAuth = FirebaseAuth.getInstance();
   mFirebaseDatabase = FirebaseDatabase.getInstance();
   mMessagesDatabaseReference = mFirebaseDatabase.getReference().child("USERS");
    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            user = firebaseAuth.getCurrentUser();
            if (user != null) {
                // User is signed in
                Toast.makeText(MainActivity.this, "You're now signed in. Welcome.", Toast.LENGTH_SHORT).show();
                onSignedInInitialize(user.getDisplayName());
                Log.d("TAG", "onAuthStateChanged:signed_in:" + user.getUid());
            } else {
                // User is signed out
                onSignedOutCleanup();
                startActivityForResult(
                        AuthUI.getInstance()
                                .createSignInIntentBuilder()
                                .setIsSmartLockEnabled(false)
                                .setProviders(Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
                                        new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build()))
                                .build(),
                        RC_SIGN_IN);
                Log.d("TAG", "onAuthStateChanged:signed_out");
            }
        }
    };
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_SIGN_IN) {
        if (resultCode == RESULT_OK) {
            // Sign-in succeeded, set up the UI
            //Toast.makeText(this, "Signed in!", Toast.LENGTH_SHORT).show();
        } else if (resultCode == RESULT_CANCELED) {
            // Sign in was canceled by the user, finish the activity
            Toast.makeText(this, "Sign in canceled", Toast.LENGTH_SHORT).show();
            finish();
        }
    }
}

@Override
protected void onStart() {
    super.onStart();
    mAuth.addAuthStateListener(mAuthListener);
}

@Override
protected void onStop() {
    super.onStop();
    mAuth.removeAuthStateListener(mAuthListener);
}

@Override
protected void onResume() {
    super.onResume();
    mAuth.addAuthStateListener(mAuthListener);
}

@Override
protected void onPause() {
    super.onPause();
    if(mAuthListener != null) {
        mAuth.removeAuthStateListener(mAuthListener);
    }
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    mAuth.signOut();
    onSignedOutCleanup();
    return super.onOptionsItemSelected(item);
}
private void onSignedInInitialize(String username) {
    String Name = username;
    if(!preferences.contains("pan")){

        Intent extendedsignup = new Intent(MainActivity.this,ExtendedSignUp.class);
        startActivity(extendedsignup);
    }
    //Database work here
    chechker.setText(Name);

}
private void onSignedOutCleanup() {
    mUsername = ANONYMOUS;
    user = null;
}

}

我该怎么办?提前感谢

我更新了我的清单:-

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:cardview-v7:25.3.1'
compile 'com.android.support:customtabs:25.3.1'
compile 'com.google.firebase:firebase-database:10.2.4'
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.firebaseui:firebase-ui-auth:1.2.0'

testCompile 'junit:junit:4.12'
}

现在似乎一切正常。

检查您的版本。对于Firebase SDK版本10.0.1,请使用FirebaseUI 1.1.1。兼容版本表也可参见@BobSnyder:我正在更新链接的答案,因为很难回答Github文档中的问题。:-)是的,更改了版本,现在工作得很好。谢谢:)
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:cardview-v7:25.3.1'
compile 'com.android.support:customtabs:25.3.1'
compile 'com.google.firebase:firebase-database:10.2.4'
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.firebaseui:firebase-ui-auth:1.2.0'

testCompile 'junit:junit:4.12'
}