java.lang.NoSuchMethodException: android.os.MessageQueue#enableMonitor()

1

UPDATED QUESTION

I have a launcher activity UserEmailAuth that has a button to handle user login by Firebase's GoogleSignIn. When I try to make the UserEmailAuth the LAUNCHER Activity, the app does not launch from any of the methods: USB Installation, Emulator, or Generated APK.

But, interestingly, when I bypass the user login and make my MainActivity as the launcher activity and then press the LogOut from the MainActivity, it is redirected back to the UserEmailAuth from there it works fine.

Following is the trace, which is not an error and is generated regardless of the Bypass Method or the Original Method.

W/ReflectionUtils: java.lang.NoSuchMethodException: android.os.MessageQueue#enableMonitor()#bestmatch
        at miui.util.ReflectionUtils.findMethodBestMatch(ReflectionUtils.java:338)
        at miui.util.ReflectionUtils.findMethodBestMatch(ReflectionUtils.java:375)
        at miui.util.ReflectionUtils.callMethod(ReflectionUtils.java:800)
        at miui.util.ReflectionUtils.tryCallMethod(ReflectionUtils.java:818)
        at android.os.BaseLooper.enableMonitor(BaseLooper.java:47)
        at android.os.Looper.prepareMainLooper(Looper.java:112)
        at android.app.ActivityThread.main(ActivityThread.java:6371)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:930)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:820)
V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@267c3e2
W/System: ClassLoader referenced unknown path: /data/app/com.bytebeetech.wildtripurafoundation-2/lib/arm64
W/ResourceType: No package identifier when getting name for resource number 0x00000000
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
I/FirebaseInitProvider: FirebaseApp initialization successful
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
W/ResourceType: No package identifier when getting name for resource number 0x00000000
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
D/AccessibilityManager: current package=com.bytebeetech.wildtripurafoundation, accessibility manager mIsFinalEnabled=false, mOptimizeEnabled=false, mIsUiAutomationEnabled=false, mIsInterestedPackage=false
I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
        at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2421)
        at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:779)
        at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:659)
I/art:     at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:552)
        at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:161)
I/art:     at void com.bytebeetech.wildtripurafoundation.user.activities.UserEmailAuthentication.onCreate(android.os.Bundle) (UserEmailAuthentication.java:60)
        at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6854)
I/art:     at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1119)
        at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2709)
        at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2817)
        at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)

Below is the class which implements the logic of GoogleSignInOptions

UserEmailAuthentication.java

public class UserEmailAuthentication extends AppCompatActivity {

    private FirebaseAuth firebaseAuth;
    private FirebaseFirestore db = FirebaseFirestore.getInstance();

    private static final int RC_SIGN_IN = 101;

    public static final String SHARED_PREFS = "sharedPreferences";
    public static final String IS_ADMIN = "is_admin";

    public String is_admin;

    Button signUpButton;
    GoogleSignInOptions gso;
    GoogleSignInClient mGoogleSignInClient;

    UserUtility userUtility = new UserUtility(UserEmailAuthentication.this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_email_authentication);
        firebaseAuth = FirebaseAuth.getInstance();

        init();
        // Configure Google Sign In
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(getString(R.string.default_web_client_id))
                .requestEmail()
                .build();
        // Build a GoogleSignInClient with the options specified by gso.
        mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
        View view = findViewById(R.id.myProgressButton);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (userUtility.checkInternetConnection(getApplicationContext())) {
                    ProgressUtility progressUtility = new ProgressUtility(getApplicationContext(), v);
                    progressUtility.buttonActivated();
                    signIn();
                } else {
                    userUtility.showSnackbar("You are not connected to the INTERNET", v, getApplicationContext());
                }
            }
        });
    }

    @Override
    protected void onStart() {
        super.onStart();
        checkUserProfile(firebaseAuth);
    }


    private void signIn() {
        Log.d("Inside", "signIn: ");
        Intent signInIntent = mGoogleSignInClient.getSignInIntent();
        startActivityForResult(signInIntent, RC_SIGN_IN);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
        if (requestCode == RC_SIGN_IN) {
            Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
            try {
                GoogleSignInAccount account = task.getResult(ApiException.class);
                Log.d("Inside", "onActivityResult: ");
                firebaseAuthWithGoogle(account.getIdToken());
            } catch (ApiException e) {
                Toast.makeText(this, "SignIn Failed, Please Try Again", Toast.LENGTH_LONG).show();
                startActivity(new Intent(UserEmailAuthentication.this, UserEmailAuthentication.class));
                finish();
            }
        }
    }

    private void firebaseAuthWithGoogle(String idToken) {
        // SHOW PROGRESS BAR
        AuthCredential credential = GoogleAuthProvider.getCredential(idToken, null);
        firebaseAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            checkUserProfile(firebaseAuth);
                        } else {
                            Log.d("---------------", "------------------------");
                            Log.d("Error ","Message: "+task.getException());
                            Log.d("---------------", "------------------------");
                        }
                    }
                    // HIDE PROGRESS BAR
                });
    }

    private void checkUserProfile(FirebaseAuth firebaseAuth) {
        final FirebaseUser currentFirebaseUser = firebaseAuth.getCurrentUser();
        if (currentFirebaseUser != null) {
            String user_id = currentFirebaseUser.getEmail();
            db.collection("users").document(user_id).get()
                    .addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
                        @Override
                        public void onSuccess(DocumentSnapshot documentSnapshot) {
                            if (documentSnapshot.exists()) {
                                String is_admin = documentSnapshot.getString("is_admin");
                                saveSharedData(is_admin);
                                if(is_admin.equals("true")) {
                                    Intent intent = new Intent(UserEmailAuthentication.this, AdminActivity.class);
                                    View view  = findViewById(R.id.myProgressButton);
                                    ProgressUtility progressUtility = new ProgressUtility(getApplicationContext(), view);
                                    progressUtility.buttonFinished();
                                    Handler handler = new Handler();
                                    handler.postDelayed(new Runnable() {
                                        @Override
                                        public void run() {
                                            startActivity(intent);
                                            finish();
                                        }
                                    }, 3000);

                                } else if(is_admin.equals("false")) {
                                    Intent intent = new Intent(UserEmailAuthentication.this, MainActivity.class);
                                    startActivity(intent);
                                    finish();
                                }
                            } else {
                                //String is_admin = documentSnapshot.getString("is_admin");
                                //saveSharedData(is_admin);
                                String user_email = currentFirebaseUser.getEmail();
                                String user_photo_url = currentFirebaseUser.getPhotoUrl().toString();
                                Intent intent = new Intent(UserEmailAuthentication.this, UserDataAuthentication.class);
                                startActivity(intent);
                                Toast.makeText(UserEmailAuthentication.this, "Passing Email: " + user_email, Toast.LENGTH_SHORT).show();
                                finish();
                            }
                        }
                    })
                    .addOnFailureListener(new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception e) {
                            Toast.makeText(UserEmailAuthentication.this, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
                        }
                    });
        } else {
            Toast.makeText(this, "Please SignIn", Toast.LENGTH_SHORT).show();
        }
    }

    public void saveSharedData(String is_admin) {
        SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(IS_ADMIN, is_admin);
        editor.apply();
    }

}

Using these for my project to support Firebase Functionalities


    implementation "com.google.android.gms:play-services-location:17.0.0"
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.android.gms:play-services-auth:18.0.0'
   
    implementation 'com.google.firebase:firebase-auth:19.3.1'
    implementation 'com.google.firebase:firebase-database:19.3.0'
    implementation 'com.google.firebase:firebase-firestore:21.4.3'
    implementation 'com.google.firebase:firebase-storage:19.1.1'
    implementation 'com.firebaseui:firebase-ui-firestore:6.2.1'
    implementation 'com.google.firebase:firebase-messaging:20.2.0'

ProgressUtility.java

public class ProgressUtility {

    private MaterialCardView materialCardView;
    private ProgressBar progressBar;
    private ConstraintLayout constraintLayout;
    private TextView textView;

    Animation fadeIn;

    public ProgressUtility(Context context, View view) {
        materialCardView = view.findViewById(R.id.cardViewProgressBtn);
        constraintLayout = view.findViewById(R.id.constraintLayoutProgressBtn);
        progressBar = view.findViewById(R.id.progressBar2);
        textView = view.findViewById(R.id.msgText);
    }

    public void buttonActivated() {
        progressBar.setVisibility(View.VISIBLE);
        textView.setText("Please Wait...");
    }

    public void buttonFinished() {
        constraintLayout.setBackgroundColor(materialCardView.getResources().getColor(R.color.colorPrimaryDark));
        progressBar.setVisibility(View.GONE);
        textView.setText("Done");
    }
}

progress_btn_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.material.card.MaterialCardView
        android:id="@+id/cardViewProgressBtn"
        android:layout_width="match_parent"
        android:layout_height="54dp"
        app:cardCornerRadius="32dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/constraintLayoutProgressBtn"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorGoogle">

            <ProgressBar
                android:id="@+id/progressBar2"
                style="?android:attr/progressBarStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="8dp"
                android:indeterminate="true"
                android:indeterminateTint="@color/yellow"
                android:indeterminateTintMode="src_atop"
                android:visibility="gone"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/msgText"
                app:layout_constraintHorizontal_bias="0.917"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/msgText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Continue with Google"
                android:textColor="@color/white"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
        </androidx.constraintlayout.widget.ConstraintLayout>

    </com.google.android.material.card.MaterialCardView>

</androidx.constraintlayout.widget.ConstraintLayout>

user_email_auth.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/constraintLayoutEmailAuth"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/activityBackground"
    android:padding="24dp"
    tools:context=".user.activities.UserEmailAuthentication">

    <include
        android:id="@+id/myProgressButton"
        layout="@layout/progress_btn_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>

This is the class where the layout is initiated which has one Google Sign in button. Even if I remove the sign option and implement a simple Toast, the errors are the same.

I have also Invalidate the Cache and Restarted and Cleaned and rebuilt as I have no idea where it is coming from.

I even do not know whether it is due to a Firebase Version Conflict or on my MIUI Problem (Xiaomi Version COnflict). Even on the Emulator, it has the same errors.

Any suggestions would help

java
android
firebase
asked on Stack Overflow Jul 6, 2020 by dope • edited Jul 7, 2020 by dope

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0