8

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

KENdi
  • 7,576
  • 2
  • 16
  • 31
Kharak
  • 384
  • 5
  • 19
  • `have you declared this activity in your AndroidManifest.xml`?? – Vladyslav Matviienko Aug 03 '17 at 06:53
  • 2
    The activity should've been added for you. Open the merged manifest as descibed here https://developer.android.com/studio/build/manifest-merge.html#inspect_the_merged_manifest_and_find_conflicts and make sure all activities listed here https://github.com/firebase/FirebaseUI-Android/blob/version-1.1.1/auth/src/main/AndroidManifest.xml are added – Eugen Pechanec Aug 03 '17 at 07:26
  • I can't open merged manifest, at the bottom of manifest file, i don't have merged manifest tab in bottom of editor, I am using android studio 2.1 – Kharak Aug 03 '17 at 08:15
  • i went to this path /project/module/build/intermediates/manifests/full/debug/AndroidManifest.xml. and if it is what i should look for then it has no activities added that is listed in link provided by you. – Kharak Aug 03 '17 at 08:21
  • I have checked the repo of Firebase UI, there are newer versions on dependencies available: compile 'com.firebaseui:firebase-ui-auth:2.2.0' Also other firebase dependencies can be renewed to 11.0.4 – Deividas Strioga Aug 03 '17 at 08:45

5 Answers5

6

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>
Ritt
  • 3,181
  • 3
  • 22
  • 51
  • these libraries should be added automatically, there are lot of activities in firebaseAuthUI.correct me if i am wrong. – Kharak Aug 18 '17 at 03:40
  • what libraries? you need to declare activity in the manifest ryt and also init the firebase.Just adding dependency wont help in any case.please, read firebase doc. And have your tried the same yet? – Ritt Aug 18 '17 at 03:47
  • I am sorry for saying it library, its activities i was talking about, which should be added with dependencies of AuthUI. On adding activity to manifest it show an compile error unresolved class kickoffActivity. – Kharak Aug 18 '17 at 03:53
  • post ur activity and manifest file. check the activity path which you have given. – Ritt Aug 18 '17 at 03:55
  • I didn't created any kickoffactivity – Kharak Aug 18 '17 at 04:07
1

Manually adding the KickoffActivity activity to the manifest is not the right solution. It should be done for you. If you manually add the KickoffActivity, you will then have to add another activity and another one and so on. I happened to have:

tools:node="replace">

In my manifest. Which prevents any manifest merging. Removed it and it worked fine since.

After that you might get some other merging errors like duplicate tags etc.. But the error will be different and will tell you what to do now. I had a case of a tag used twice in my and in a merged manifest so I was told to add:

tools:replace="android:label"

Which fixed that too.

psydj1
  • 181
  • 10
0

Make sure your have declared your KickoffActivity properly in AndroidManifest.xml as

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xxx.xxx.xxx">
<application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <activity android:name=".KickoffActivity">
        </activity>
    </application>

</manifest>

Especially check the name attribute, if you have activity in package say "test" then you'll have to change the name attribute as

<activity android:name=".test.KickoffActivity">
            </activity>

If everything fine with AndroidManifest.xml, I would suggest to update your libraries as mentioned by deividas.

You can check the FirebaseUI release notes here https://github.com/firebase/FirebaseUI-Android/releases

Also update other firebase libraries to

 compile 'com.google.firebase:firebase-core:11.0.4' 
 compile 'com.google.firebase:firebase-auth:11.0.4'
Man
  • 2,720
  • 2
  • 13
  • 21
0

Finally I have completely reinstall android studio to latest version, updated everything including

  • Google play service
  • firebase libraries
  • gradle version
  • google repositoris

And I started new project from begining and worked with no error. there are many activities that are added automatically on adding AUTHUI dependencies. these activity includes kickoffactivity,recoverpasswordactivity,registerEmailActivity,etc I can verify if by going to path

/project/module/build/intermediates/manifests/full/debug/And‌​roidManifest.xml.

previously i don't have kickoffactivity in this manifest file, I don't know the reason,but now i have it.I don't think adding it manually on app's manifest file will work.

Kharak
  • 384
  • 5
  • 19
0

Add the following in the manifest file:

< activity android :name=" *name of the activity* ">
            < /activity>

The above is added by default inside the manifest, but in case if it is not, then do add it.

Abhishek Dutt
  • 1,308
  • 7
  • 14
  • 24