简体   繁体   中英

Have you declared this activity in your AndroidManifest.xml ? LoginActivity

I keep getting this error even though my activity is in the android manifest file as the launcher.

Unable to find explicit activity class {com.alpha.hifivepro/com.alpha.hifivepro.activities.LoginActivity}; have you declared this activity in your AndroidManifest.xml?

And I am getting errors at these three locations. When the user clicks the logout button they are supposed to go to the loginactivity but I keep getting the above error. Any help please ?

    private void handleLogout() {

        mAuth.signOut();
        SendUserToLoginActivity();

    }

    private void SendUserToLoginActivity() {

        Intent loginIntent = new Intent(MainActivity.this, LoginActivity.class);
        loginIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(loginIntent);
    }

AndroidManifest.xml

    <application
        android:name=".utils.MyApp"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="false"
        android:theme="@style/AppTheme"
        tools:replace="android:supportsRtl,android:allowBackup">
        <activity android:name=".activities.authentication.RegisterActivity"></activity>
        <!--
             The API key for Google Maps-based APIs is defined as a string resource.
             (See the file "res/values/google_maps_api.xml").
             Note that the API key is linked to the encryption key used to sign the APK.
             You need a different API key for each encryption key, including the release key that is used to
             sign the APK for publishing.
             You can define the keys for the debug and release targets in src/debug/ and src/release/.
        -->
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <activity
            android:name=".activities.PickPlaceMapsActivity"
            android:label="@string/title_activity_pick_place_maps" />
        <activity
            android:name=".activities.authentication.LoginActivity"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

Your manifest has .activities.authentication.LoginActivity , but the error says .activities.LoginActivity . You need to either correct your manifest to use the same package name or move LoginActivity to the authentication package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM