Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

后端 未结 30 1524
野的像风
野的像风 2020-11-22 12:51

This is the output of my Gradle console, I am unable to build my project

D:\\Android Projects\\....\\app\\src\\main\\res\\layout\\topic_view_header.xml
Error         


        
30条回答
  •  太阳男子
    2020-11-22 13:30

    UPDATE

    A new version of Gradle and Android-gradle-plugin is available that fixes these issues.

    build.gradle (top level)

    buildscript {
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
        }
    }
    

    gradle-wrapper.properties

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip
    

    PREVIOUS ANSWER

    If you disable AAPT2 you are just hiding the real issue.

    Please be aware that AAPT1might be removed in the future therefore you are forced to use AAPT2. Actually the migration guide isn't hard to follow since you don't see that much changes at the same time this way is future proof.

    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:

    
       
               
                   
                   
               
               
           
       
    
    

    Therefore you must check first if your really follow the correct Manifest structure as showed below.

    Manifest file structure

    The code snippet below shows the general structure of the manifest file and every element that it can contain. Each element, along with all of its attributes, is fully documented in a separate file.

    
    
        
        
        
        
        
        
          
          
          
          
          
    
        
    
            
                
                    
                    
                    
                
                
            
    
            
                 . . . 
                
            
    
            
                 . . . 
                
            
    
            
                 . . . 
                
            
    
            
                
                
                
            
    
            
    
        
    
    
    

提交回复
热议问题