Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to solve Unable to find explicit activity in firebase AuthUi?

While working with firebase UI I am getting Unable to find explicit activity class com.firebase.ui.auth.KickoffActivity

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FirebaseApp.initializeApp(this);
    setContentView(R.layout.activity_main);
    FirebaseApp.initializeApp(this);
    mAuth=FirebaseAuth.getInstance();
    mAuthListner=new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            FirebaseUser user=firebaseAuth.getCurrentUser();
            if(user!=null){
                Toast.makeText(getApplicationContext(),"Sign in success",Toast.LENGTH_SHORT).show();

            }
            else {
                startActivityForResult(AuthUI.getInstance()
                        .createSignInIntentBuilder()
                        .setIsSmartLockEnabled(false)
                        .setProviders(AuthUI.EMAIL_PROVIDER,AuthUI.GOOGLE_PROVIDER).build(),
                        RC_SIGN_IN);
            }
        }
    };
}

Full error message

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.flamanco.trackme/com.firebase.ui.auth.KickoffActivity}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult

Added dependencies on app/.gradle file

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-auth:10.0.1'
    compile 'com.firebaseui:firebase-ui-auth:1.1.1'
}

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

also added plugin in build gradle

classpath 'com.google.gms:google-services:3.0.0'

Finally I did added SHA1 fingerprint in my firebase console project.

Do I need to add auth.kickOff activity in manifest file

like image 949
Kharak Avatar asked Aug 03 '17 06:08

Kharak


People also ask

How do you check if a user is authenticated in Firebase?

You can easily detect if the user is logged or not by executing: var user = firebase. auth().

What does Firebase auth () currentUser return?

auth(). currentUser) // This returns null console.

What is FirebaseUI?

FirebaseUI is a library built on top of the Firebase Authentication SDK that provides drop-in UI flows for use in your app.


1 Answers

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.flamanco.trackme/com.firebase.ui.auth.KickoffActivity}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult

You need to declare the activity in the AndroidManifest.xml

Open your manifest file and add the KicoffActivity.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:installLocation="auto">
<activity
            android:name="KickoffActivity"/>
</manifest>

Also, I am not sure you have initial FirebaseApp twice here..

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FirebaseApp.initializeApp(this);
    setContentView(R.layout.activity_main);
    FirebaseApp.initializeApp(this);
}

Usually it should be initialized only once in the application class, in onCreate() method.

Create a new application class..

public class YourApplicationClass extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        FirebaseApp.initializeApp(this);
    }
}

And add the same in the manifest,

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:installLocation="auto">
<application
        android:name="YourApplicationClass"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:theme="@style/MyMaterialTheme.Base">
       <activity
        android:name="KickoffActivity"/>
</application>
</manifest>
like image 131
Ritt Avatar answered Oct 07 '22 23:10

Ritt