Android Studio 3.0 Manifest Error: unknown element found

前端 未结 8 1540
自闭症患者
自闭症患者 2020-11-28 11:28

NOTICE: Please do not post this \"android.enableAapt2=false\" as an answer. It is not a solution. It is jus

相关标签:
8条回答
  • 2020-11-28 12:09

    In order to summarize and simplify: you should just concentrate on your main AndroidManifest.xml file and check whether it strictly follows the sequence as well as nesting of XML tags as described in https://developer.android.com/guide/topics/manifest/manifest-intro.html. Otherwise the IDE will open up the debug-level AndroidManifest.xml showing a lot of error every time you try to clean/build the project and make you confused!

    0 讨论(0)
  • 2020-11-28 12:10

    I recently had this fix on my gradle.properties but a warning saying that "The option 'android.enableAapt2' is deprecated..." kept on coming and the solution was to change it to true instead.

    0 讨论(0)
  • 2020-11-28 12:11

    We have the solution of this problem and solution is that service always comes under child form of <Application <service>> when we write the code outside of <Application> then issue occur. Services are the child part of Application in Manifest... okay... It will sure work..do it

    0 讨论(0)
  • 2020-11-28 12:12

    Put action content in intent-filter like below as per Manifest file structure.

    <intent-filter>
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
     </intent-filter>
    
    0 讨论(0)
  • 2020-11-28 12:14

    You have a misplaced tag. The new AAPT (AAPT2) now throws an error on this.

    From the docs in here: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html

    Behavior changes when using AAPT2


    To improve incremental resource processing, Android plugin 3.0.0 enables AAPT2 by default. Although AAPT2 should immediately work with older projects, this section describes some behavior changes that you should be aware of.

    Element hierarchies in the Android manifest

    In previous versions of AAPT, elements nested in incorrect nodes in the Android manifest are either ignored or result in a warning. For example, consider the following sample:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.example.myname.myapplication">
       <application
           ...
           <activity android:name=".MainActivity">
               <intent-filter>
                   <action android:name="android.intent.action.MAIN" />
                   <category android:name="android.intent.category.LAUNCHER" />
               </intent-filter>
               <action android:name="android.intent.action.CUSTOM" />
           </activity>
       </application>
    </manifest>
    

    Previous versions of AAPT would simply ignore the misplaced tag. However, with AAPT2, you get the following error:

    AndroidManifest.xml:15: error: unknown element <action> found.
    

    To resolve the issue, make sure your manifest elements are nested correctly. For more information, read Manifest file structure.

    0 讨论(0)
  • 2020-11-28 12:16

    add this code in gradle.properties in the root project:

    android.enableAapt2=false
    

    this worked for me

    root 
    | 
    |--gradle.properties
    
    0 讨论(0)
提交回复
热议问题