Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi android enthusiast,

I hope the lockdown is not taking it's on you all, we will surely survive this pandemic

I implemented firenase email/password authemtication in my app which is working well until I migrated my app androidx during test
on clicking on the login button the app crashes and shows the following error message in the logcat

java.lang.IllegalStateException: Not allowed to start service Intent { cmp=com.google.android.apps.messaging/.shared.datamodel.action.execution.ActionExecutorImpl$EmptyService }: app is in background uid UidRecord{dceaaa5 u0a102 CEM idle change:cached procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1577)
at android.app.ContextImpl.startService(ContextImpl.java:1532)
at android.content.ContextWrapper.startService(ContextWrapper.java:664)
at com.google.android.apps.messaging.shared.datamodel.action.execution.ActionExecutorImpl.a(PG:97)
at com.google.android.apps.messaging.shared.datamodel.action.execution.ActionExecutorImpl.a(PG:91)
at exo.c(PG:111)
at exl.run(PG:1)
at uev.run(PG:3)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6852)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:504)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

See below the ObClickListener for the login button

Java
private void loginBronze() {
        //We get the email and password from the text boxes
        final String email = bronzeEmail.getText().toString().trim();
        String password = bronzePassword.getText().toString().trim();

        //We verify that the text boxes are not empty
        if (TextUtils.isEmpty(email)) {//(precio.equals(""))
            Toast.makeText(this, "You must enter an email", Toast.LENGTH_LONG).show();
            return;
        }

        if (TextUtils.isEmpty(password)) {
            Toast.makeText(this, "Password is missing", Toast.LENGTH_LONG).show();
            return;
        }


        progressDialog.setMessage("Performing online consultation ...");
        progressDialog.show();

        //loguear usuario
        firebaseAuth.signInWithEmailAndPassword(email, password)
                .addOnCompleteListener((Executor) this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        //checking if success
                        if (task.isSuccessful()) {
                            int pos = email.indexOf("@");
                            String user = email.substring(0, pos);
                            Toast.makeText(BronzeActivationPage.this, "Bienvenido: " + bronzeEmail.getText(), Toast.LENGTH_LONG).show();
                            Intent intencion = new Intent(getApplication(), BronzePackageHome.class);
                            intencion.putExtra(BronzePackageHome.user, user);
                            startActivity(intencion);


                        } else {
                            if (task.getException() instanceof FirebaseAuthUserCollisionException) {//si se presenta una colisión
                                Toast.makeText(BronzeActivationPage.this, "That user already exists ", Toast.LENGTH_SHORT).show();
                            } else {
                                Toast.makeText(BronzeActivationPage.this, "Could not login ", Toast.LENGTH_LONG).show();
                            }
                        }
                        progressDialog.dismiss();
                    }
                });


    }


When i google for the solution i came across the below url on stackoverflow but i don't really understand how to implement the
solution in my code
https://stackoverflow.com/questions/46445265/android-8-0-java-lang-illegalstateexception-not-allowed-to-start-service-inten

Kindly help

What I have tried:

When i google for the solution i came across the below url on stackoverflow but i don't really understand how to implement the
solution in my code
https://stackoverflow.com/questions/46445265/android-8-0-java-lang-illegalstateexception-not-allowed-to-start-service-inten
Posted
Updated 23-Jul-20 23:34pm

1 solution

What is this
.addOnCompleteListener((Executor) this, new OnCompleteListener<AuthResult>()


I have a sneaky suspision it has to do with the bold parameter in your OnCompleteListener.

Also, have a look at your gradle build file for the app. Roll your Firebase back one version and see if you can duplicate the error.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900