没有响应signinWithEmailAndPassword android

时间:2017-08-18 14:00:02

标签: android firebase firebase-authentication onesignal

我尝试将OneSignal集成到设备之间的推送通知,但我不断收到以下错误。当我将firebase依赖项升级到11.2.0时,此错误将消失,但signinWithEmailAndPasswordCreateAccountWithEmailAndPassword不再起作用。

FATAL EXCEPTION: main java.lang.NoSuchMethodError: No static method zzb(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzac; or its super classes (declaration of 'com.google.android.gms.common.internal.zzac' appears in /data/app/com.example.ries.ecpay-c-FGodiJGHeJlywws_hhvA==/base.apk:classes10.dex)
    at com.google.firebase.provider.FirebaseInitProvider.zza(Unknown Source:2)
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:0)
    at android.app.ActivityThread.installProvider(ActivityThread.java:6285)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5851)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5772)
    at android.app.ActivityThread.-wrap1(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)<

我的依赖项:当我将依赖项更改为11.2.0时,上述错误消失但后来signinWithEmailAndPassword方法不再执行任何操作。

compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-auth:10.0.1'
compile 'com.firebase:firebase-client-android:2.5.2'
testCompile 'junit:junit:4.12'
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
compile 'com.google.android.gms:play-services-gcm'

compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-analytics:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'

compile 'com.google.android.gms:play-services-gcm:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'

compile 'com.android.support:support-v4:26.0.0'
compile 'com.android.support:customtabs:26.0.0'
compile 'com.android.support:multidex:1.0.1'< 

我在firebase中使用电子邮件/密码打开登录。但它不会进入onComplete。

    mAuth = FirebaseAuth.getInstance();
    Log.d("test", "auth get instance oncreate " + mAuth);
    firebaseDatabase = FirebaseDatabase.getInstance();
    mRef = firebaseDatabase.getReference();
    FirebaseUser user = mAuth.getCurrentUser();

    signInBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String email = mEmail.getText().toString();
            String pass = mPassword.getText().toString();

            if(!email.isEmpty() && !pass.isEmpty()) {
                Log.d("test", "in if not empty");
                mAuth.signInWithEmailAndPassword(email, pass).addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        Log.d("test", "in oncomplete");
                        task.getException().getMessage();
                        if (task.isSuccessful()) {
                            Log.i("Task:", "Complete");
                            Intent i = new Intent(MainActivity.this, AccountActivity.class);
                            startActivity(i);
                        }

                        if (!task.isSuccessful()) {
                            Toast.makeText(MainActivity.this, "Login Failed",
                                    Toast.LENGTH_SHORT).show();
                        }
                    }
                });          

1 个答案:

答案 0 :(得分:0)

如果您忘记添加播放服务,请将它们添加到build.gradle

use if defined $ENV{AC},
    lib => do { no warnings 'uninitialized'; "$ENV{AC}/lib" };

并将您的firebase库更新为

apply plugin: 'com.google.gms.google-services'