的本地模块描述符类

的本地模块描述符类

本文介绍了Android auth firebase 错误:找不到 com.google.firebase.auth 的本地模块描述符类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我正在尝试通过 Firebase 构建具有登录/注册功能的应用.我正在与合作伙伴(他在 Linux 上,我在 Mac 上)一起工作,他能够使身份验证正常工作,但由于某种原因我不能.我们在 SDK 管理器中检查了所有相同的代码、SDK 工具,运行相同版本的所有内容.
  • 这是 gradle 文件:

  • I'm trying to build an app with login/register capabilities through Firebase. I'm working on it with a partner (he's on Linux, I'm on Mac), and he's able to get the authentication working but for some reason I am not. We have all the same code, SDK tools checked in the SDK manager, running the same version of everything.
  • Here's the gradle file:


compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.android.support:design:25.3.0'
testCompile 'junit:junit:4.12'

  • 还有代码:

  • And the code:

    
    
        public class RegisterActivity extends AppCompatActivity {
        private FirebaseAuth mAuth;
        private FirebaseAuth.AuthStateListener mAuthListener;
    
        private EditText mUsernameField;
        private EditText mPasswordField;
        private EditText mConfirmPasswordField;
    
        private Button mRegisterButton;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_register);
            Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
            setSupportActionBar(toolbar);
    
            mUsernameField = (EditText) findViewById(R.id.enterUsername);
            mPasswordField = (EditText) findViewById(R.id.enterPassword);
            mConfirmPasswordField = (EditText) findViewById(R.id.confirmPassword);
            mRegisterButton = (Button) findViewById(R.id.confirmRegistration);
    
            mRegisterButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    createAccount(mUsernameField.getText().toString(), mPasswordField.getText().toString());
                }
            });
            mAuth = FirebaseAuth.getInstance();
    
            mAuthListener = new FirebaseAuth.AuthStateListener() {
                @Override
                public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                    FirebaseUser user = firebaseAuth.getCurrentUser();
                    if (user != null) {
                        // User is signed in
                        Log.d("account", "onAuthStateChanged:signed_in:" + user.getUid());
                    } else {
                        // User is signed out
                        Log.d("account", "onAuthStateChanged:signed_out");
                    }
                    // ...
                }
            };
        }
    
        @Override
        public void onStart() {
            super.onStart();
            mAuth.addAuthStateListener(mAuthListener);
        }
    
        @Override
        public void onStop() {
            super.onStop();
            if (mAuthListener != null) {
                mAuth.removeAuthStateListener(mAuthListener);
            }
        }
    
        private void createAccount(String email, String password) {
            Log.d("account", "createAccount:" + email);
            if (!validateForm()) {
                return;
            }
    
            // [START create_user_with_email]
            mAuth.createUserWithEmailAndPassword(email, password)
                    .addOnCompleteListener(this, new OnCompleteListener() {
                        @Override
                        public void onComplete(@NonNull Task task) {
                            Log.d("account", "createUserWithEmail:onComplete:" + task.isSuccessful());
    
                            // 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.
                            if (!task.isSuccessful()) {
                                Toast.makeText(RegisterActivity.this, R.string.register_failed,
                                        Toast.LENGTH_SHORT).show();
                            }
    
                            else {
                                Intent intent = new Intent(RegisterActivity.this, MainActivity.class);
                                RegisterActivity.this.startActivity(intent);
                                finish();
                            }
                        }
                    });
            // [END create_user_with_email]
        }
    
        private boolean validateForm() {
            boolean valid = true;
    
            String email = mUsernameField.getText().toString();
            if (TextUtils.isEmpty(email)) {
                mUsernameField.setError("Required.");
                valid = false;
            } else {
                mUsernameField.setError(null);
            }
    
            String password = mPasswordField.getText().toString();
            if (TextUtils.isEmpty(password)) {
                mPasswordField.setError("Required.");
                valid = false;
            } else {
                mPasswordField.setError(null);
            }
    
            String confirmPassword = mConfirmPasswordField.getText().toString();
            if (TextUtils.isEmpty(confirmPassword)) {
                mConfirmPasswordField.setError("Required.");
                valid = false;
            } else {
                mConfirmPasswordField.setError(null);
            }
    
            if(!confirmPassword.equals(password)) {
                mConfirmPasswordField.setError("Passwords must be the same.");
                valid = false;
            }
    
            return valid;
        }
    
    }
    
     

    • 最后是错误:
    • W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
      W/GooglePlayServicesUtil: Google Play Store is missing.
      I/art: Background partial concurrent mark sweep GC freed 5866(313KB) AllocSpace objects, 1(14KB) LOS objects, 39% free, 2MB/4MB, paused 5.176ms total 27.761ms
      D/account: createUserWithEmail:onComplete:false 
      • 几乎所有内容都取自 Firebase 网站的教科书.请帮忙,我们已经被困在这个问题上好几个小时了,其他类似的问题都没有帮助.

      推荐答案

      选项 1:转到 Firebase 控制台认证登录方法,看看您是否在匿名状态下使用它.如果是,请禁用它并启用电子邮件/密码或您使用的任何登录方法.

      Option 1: Go to Firebase Console < Authentication < SIGN-IN METHOD, and see if you are using it in the Anonymous state. If you are, disable that and enable Email/Password or whichever login method you are using.

      选项 2:检查您正在测试的设备是否正在运行 Google Play 服务 9.0.0 或更高版本.

      Option 2: Check if the device you are testing with is running Google Play Services 9.0.0 or later.

      这篇关于Android auth firebase 错误:找不到 com.google.firebase.auth 的本地模块描述符类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 08-12 20:16