【问题标题】:XML document structures must start and end within the same entity?XML 文档结构必须在同一个实体内开始和结束?
【发布时间】:2021-12-12 20:45:22
【问题描述】:

有什么问题?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.4" >

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <receiver android:name=".MainActivity"
            tools:ignore="IntentFilterExportedReceiver">

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

                </action>
            </intent-filter>
        </receiver>
    </application>

【问题讨论】:

    标签: java android android-studio android-layout


    【解决方案1】:

    您需要在&lt;/application&gt; 下结束&lt;/manifest&gt; 标签:

       (...)
       </application>
    </manifest>
    

    【讨论】:

    • 我该怎么办????清单合并失败:需要为 显式指定 android:exported。当相应组件定义了 Intent 过滤器时,面向 Android 12 及更高版本的应用需要为 android:exported 指定显式值。详情请见developer.android.com/guide/topics/manifest/…。
    • @Mohammed 这是另一个错误上升。一般需要在&lt;receiver&gt;标签中加上android:exported="true"。
    • 还有更多问题 AAPT: error: resource drawable/ic_launcher (aka com.example.4:drawable/ic_launcher) not found.
    • @Mohammed android:icon="@drawable/ic_launcher" 可能会误认为android:icon="@mipmap/ic_launcher"。
    【解决方案2】:

    在应用标签之后关闭清单标签。

    &lt;/application&gt;&lt;/manifest&gt;

    android:icon="@drawable/ic_launcher"  // check in drawable folder under res whether the default image ic_launcher is present or not. That is the default icon for your application. 
    

    【讨论】:

    • 它不断添加更多类似这样的错误----- 无法识别启动活动:启动活动时未找到默认活动错误
    【解决方案3】:

    您在最后一行缺少&lt;/manifest&gt;。 android:icon="@drawable/ic_launcher" 也可能应该更改为 android:icon="@mipmap/ic_launcher"。

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        package="com.example.4" >
    
        <application
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name=".MainActivity"
                android:exported="true">
    
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
    </manifest>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      相关资源
      最近更新 更多