【问题标题】:AAPT2 error: check logs for details: unknown element <action> foundAAPT2 错误:检查日志以获取详细信息:找到未知元素 <action>
【发布时间】:2018-04-11 10:11:39
【问题描述】:

这是我的debug\AndroidManifest.xml

遇到很多错误,例如

此处不允许元素操作。
此处不允许使用元素类别。
这里不允许使用属性 android:versionCode。
这里不允许使用属性 android:versionName。
这里不允许使用属性 android:theme。等等。

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

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

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

        <application
            android:allowBackup="true"
            android:debuggable="true"
            android:icon="@drawable/logo_remaking2"
            android:label="@string/label"
            android:supportsRtl="true"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.company.sqh.adio.MainActivity"
                android:icon="@drawable/logo_remaking2" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity android:name="com.company.sqh.adio.registraion_form" >
                <intent-filter>
                    <action android:name="com.company.sqh.adio.registraion_form" />

                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
            </activity>
            <activity android:name="com.company.sqh.adio.contact_us" >
                <intent-filter>
                    <action android:name="com.company.sqh.adio.contact_us" />

                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
            </activity>
            <activity android:name="com.company.sqh.adio.about_us" >
                <intent-filter>
                    <action android:name="com.company.sqh.adio.about_us" />

                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
            </activity>
            <activity android:name="com.company.sqh.adio.ProfileActivity" />

            <action android:name="com.company.sqh.adio.ProfileActivity" />

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

            <activity android:name="com.company.sqh.adio.EmplyReg" />
            <activity android:name="com.company.sqh.adio.SubCategory" />
            <activity android:name="com.company.sqh.adio.User_Profile" />
            <activity android:name="com.company.sqh.adio.Emp_list" />
            <activity android:name="com.company.sqh.adio.Forgot_Pass" />

            <meta-data
                android:name="android.support.VERSION"
                android:value="26.1.0" /> <!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
            <activity
                android:name="com.google.android.gms.ads.AdActivity"
                android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
                android:theme="@android:style/Theme.Translucent" />
            <activity
                android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
                android:theme="@style/Theme.IAPTheme" />
            <activity
                android:name="com.google.android.gms.common.api.GoogleApiActivity"
                android:exported="false"
                android:theme="@android:style/Theme.Translucent.NoTitleBar" />

            <meta-data
                android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version" />
            <meta-data
                android:name="android.arch.lifecycle.VERSION"
                android:value="27.0.0-SNAPSHOT" />
        </application>

    </manifest>

请查看

【问题讨论】:

  • 将错误消息添加为文本而不是作为 Dropbox 的链接
  • 你能显示你的清单文件吗?
  • @Jens 我认为使用屏幕截图会更容易理解问题,因为有很多错误消息。
  • @MuhammadHannan 当然,但是哪一个? Debug\AndroidManifest.xml 还是 main\AndroidManifest.xml ?
  • 屏幕截图中的一个。

标签: android android-studio gradle android-manifest build.gradle


【解决方案1】:

AndroidManifest.xml:15:错误:找到未知元素。

您的标签放错了位置。

为了改进增量资源处理,Android 插件 3.0.0 默认启用 AAPT2。 在以前版本的 AAPT 中,嵌套在 Android 清单中不正确节点中的元素要么被忽略,要么导致警告。
要解决此问题,请确保您的清单元素嵌套正确.欲了解更多信息,请阅读Manifest file structure

你必须修改你的清单:

 <action android:name="com.company.sqh.adio.ProfileActivity" />         
 <category android:name="android.intent.category.DEFAULT" />

它们应该包含在 &lt;activity&gt; 标记中。

您可以阅读more here

【讨论】:

    【解决方案2】:

    在我的情况下,我遇到了这个错误 (AAPT2),使用 Cordova 构建命令构建 apk,原来这是由 ./ 路径引起的问题gradle 用户依赖。 问题是我的用户名有特殊字符的路径本身。 Gradle 正在阅读“?”而不是“Á”,创建一个新用户解决了这个问题。

    操作系统:Windows 10

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-10
      相关资源
      最近更新 更多