错误:(26)错误:找到未知元素<intent-filter>

时间:2017-11-30 23:21:34

标签: android

我有一个奇怪的错误,我无法处理它。为什么所有的线都有一个奇怪的错误? 它突然开始,为什么会发生这种情况?

这是我的Manifast:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="budgetreport.com.budgetreport"
    android:versionCode="1"
    android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="21"
    android:targetSdkVersion="26" />

<application
    android:allowBackup="true"
    android:debuggable="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:testOnly="true"
    android:theme="@style/AppTheme" >
    <activity android:name="budgetreport.com.budgetreport.MainActivity" >
        <intent-filter>
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

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

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

    <meta-data
        android:name="android.support.VERSION"
        android:value="26.1.0" />
    <meta-data
        android:name="android.arch.lifecycle.VERSION"
        android:value="27.0.0-SNAPSHOT" />

    <provider
        android:name="com.android.tools.ir.server.InstantRunContentProvider"
        android:authorities="budgetreport.com.budgetreport.com.android.tools.ir.server.InstantRunContentProvider"
        android:multiprocess="true" />
</application>

</manifest>

此错误:enter image description here

为什么所有的线都有一个奇怪的错误? enter image description here

2 个答案:

答案 0 :(得分:0)

移动此块:

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

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

应在<activity> TAG的</activity>MainActivity之间插入此块

答案 1 :(得分:0)

如果您想将MainActivity作为照片,则应将其添加到Activity标记中。它不会直接在application标记中使用。

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

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

在您的代码中尝试此操作。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="budgetreport.com.budgetreport"
      android:versionCode="1"
      android:versionName="1.0">

<uses-sdk
    android:minSdkVersion="21"
    android:targetSdkVersion="26"/>

<application
    android:allowBackup="true"
    android:debuggable="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:testOnly="true"
    android:theme="@style/AppTheme">
    <activity android:name="budgetreport.com.budgetreport.MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

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

    <meta-data
        android:name="android.support.VERSION"
        android:value="26.1.0"/>
    <meta-data
        android:name="android.arch.lifecycle.VERSION"
        android:value="27.0.0-SNAPSHOT"/>

    <provider
        android:name="com.android.tools.ir.server.InstantRunContentProvider"
        android:authorities="budgetreport.com.budgetreport.com.android.tools.ir.server.InstantRunContentProvider"
        android:multiprocess="true"/>
</application>
</manifest>