主要活动未在AdroidManifest.xml中声明

时间:2018-09-08 03:03:38

标签: android-studio android-manifest android-launcher

每次尝试启动我的应用程序时,都会出现以下错误。

我已经尝试在启动选项中指定活动,禁用即时运行,并在清单(以及启动选项)中更改主启动器活动,设置为“默认活动”,但无济于事。

当我在清单中添加“产品页面”活动时,一切就开始了,并将此实现添加到com.android.feature和com.android.application:

implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-core:16.0.3'



     <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="br.com.app.coffeehour.coffee_hour">

        <uses-permission android:name="android.permission.INTERNET" />

        <application
            android:label="@string/app_name"
            android:supportsRtl="true"
            android:icon="@mipmap/ic_launcher"
            android:allowBackup="true">

            <activity android:name=".home.Home"
                android:theme="@style/CustomTheme"
                android:noHistory="true"
                android:label="@string/app_name">

                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

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


            <activity android:name=".navigation.ActivityOne"
                android:theme="@style/CustomTheme"
                android:label="@string/app_name">
                <intent-filter android:order="1">
                    <action android:name="android.intent.action.VIEW" />

                    <category android:name="android.intent.category.BROWSABLE" />
                    <category android:name="android.intent.category.DEFAULT" />

                    <data
                        android:host="coffeehour.app.com.br"
                        android:pathPattern="/.*"
                        android:scheme="https" />
                </intent-filter>
            </activity>
            <activity android:name=".navigation.ActivityTwo"
                android:theme="@style/CustomTheme">
                <intent-filter android:order="1">
                    <action android:name="android.intent.action.VIEW" />

                    <category android:name="android.intent.category.BROWSABLE" />
                    <category android:name="android.intent.category.DEFAULT" />

                    <data
                        android:host="coffeehour.app.com.br"
                        android:pathPattern="/.*"
                        android:scheme="https" />
                </intent-filter>
            </activity>
            <activity android:name=".navigation.ActivityThree"
                android:theme="@style/CustomTheme"
                android:noHistory="true">
                <intent-filter android:order="1">
                    <action android:name="android.intent.action.VIEW" />

                    <category android:name="android.intent.category.BROWSABLE" />
                    <category android:name="android.intent.category.DEFAULT" />

                    <data
                        android:host="coffeehour.app.com.br"
                        android:pathPattern="/.*"
                        android:scheme="https" />
                </intent-filter>
            </activity>

 <!-- Products Page -->
        <activity
            android:name=".products.OpenScreen">
        </activity>
        <activity
            android:name=".products.NewUser"
            android:screenOrientation="portrait" />
        <activity
            android:name=".products.MainAppPage"
            android:label="@string/title_activity_main_app_page"
            android:screenOrientation="portrait"
            android:theme="@style/CustomTheme" />
        <activity
            android:name=".products.IndividualProduct"
            android:label="@string/title_activity_individual_product"
            android:screenOrientation="portrait"
            android:theme="@style/CustomTheme" />
        <activity android:name=".products.ShoppingCartWindow" />
        <activity android:name=".products.CheckOutScreen" />
        <activity android:name=".products.ForgotPassword" />
        <activity android:name=".products.IndividualProductSeller" />
        <activity android:name=".products.AddProductForm"></activity>

        </application>

    </manifest>

2 个答案:

答案 0 :(得分:0)

有时候,当您在Android Studio Manifest上更改MainActivity时,它会从缓存中进行编译,因此第一个解决问题的方法是转到-文件使缓存无效并重新启动即可解决您的问题。

答案 1 :(得分:0)

与截图相比,我更喜欢发布代码:

我已经发送了清单代码,这是MainActivity包名称:

 package br.com.app.coffeehour.coffee_hour.home;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.ImageView;
import android.support.v7.widget.Toolbar;

import br.com.app.coffeehour.coffee_hour.R;
import br.com.app.coffeehour.coffee_hour.navigation.ActivityOne;
import br.com.app.coffeehour.coffee_hour.navigation.ActivityThree;
import br.com.app.coffeehour.coffee_hour.navigation.ActivityTwo;