0

I am trying to migrate an Android Studio 3.0 project to Android Studio 3.1.1, which enables the Android gradle plugin 3.1.1 and the new AAPT2 resource processor. I think my problems stems for either of these.

Basically, when I try to gradle sync my project, the error I get is

Users/user/src/app/app-1/src/main/res/values/styles.xml:599:5-608:13: AAPT: error: :item>.

I have no idea what the error could be based on this error message alone. Googling around for it didn't seem to find anything either. The line this error message points to is nothing special, just a style declaration:

<style name=“AppEditText" parent="BigEditText">
   <item name="android:gravity">left</item>  
   <item name="android:textCursorDrawable">@drawable/drawable</item>
   <item name="android:background">@android:color/transparent</item>
   …
</style>

Based on the error position and knowing that AAPT2 is now on (it was off previously), I am concluding that the error has something to do with resources, but I have no idea what's wrong.

My project consists of two apps and a commons module both of these apps depend on. The commons module implements some UI components also. Not sure if this is relevant or not.

How would I debug this further?

Update: When I looked at the merged values.xml, as processed by AAPT2, I can see the resulting values.xml contains something strange.

<ns3:item name="layout_columnWeight">1</ns3:item>
<ns3:item name="layout_rowWeight">1</ns3:item>

It looks like the error is from these lines. But how would they have ended up there? Who would add the ns3 namespace and why?

Johan Paul
  • 2,203
  • 2
  • 22
  • 38

1 Answers1

1

Ok - I finally found out the reason for this.

As a hint for anyone else struggling with these kinds of issues, you should go to the console and do a gradle build with the --info flag and it will tell you in which file the error is happening in while it is processing the resources. This is how I managed to actually see where the error was as the issue was in one of the merged resources files that the developer normally never sees.

The issue was that in some of our XML resources files, the namespace that was specified was support and/or an namespace auto-res line was specified for an element and now caused issues with AAPT2. I don't know why it had worked before, but this was now causing issues with AAPT2. Removing those namespace declarations solves the issue.

Johan Paul
  • 2,203
  • 2
  • 22
  • 38