com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed after updating android studio

放肆的年华 提交于 2019-12-03 02:47:49

Fix this one:

Nexge_Talk_New_UI/app/src/main/res/values/ids.xml:3:5-50: AAPT: error: <item> inner element must either be a resource reference or empty.

Make sure you have no error in your ids.xml file.

BubbaGum

This is what solved the problem for me:

In my ids.xml file I had this code which worked fine before the android studio upgrade:

<resources>
    <item name="faqID" type="id">faq</item>
</resources>

Changed it to:

<resources>
    <item name="faqID" type="id"/>
</resources>

And everything is back to normal.

Just need to learn how to read error code.
Please read the error log carefully

in this case


this is the main issue on your xml

inner element must either be a resource reference or empty.

Where?

/home/protocol/DialerCheckout/WorkProjects/Nexge_Talk_New_UI/app/src/main/res/values/ids.xml

Upgrading buildVersionTools to 28.0.3 solved my issue.

In my case it was on color.xml in which invalid color name found and it did produce following error

 java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed

I checked the logcat error and I found this line of stack trace

 C:\\MyProjectPath\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml

Then I had a look into it and I found my color code was wrong then I fixed it and it compiled well.

I faced this error the android build output gave me three options i clickced Run with --stacktrace after that it rebuild and showed me the line of the error like this layout/registeration_user_fragment.xml:86: error: not well-formed (invalid token).

I migrated to AndroidX by selecting following in Android Studio Menu options

Refactor -> Migrate to AndroidX

Later I faced this AAPT issue, Linker issue etc. I fixed it by the following changes

In all modules I have updated compileSdkVersion 28

Still if you are facing issue then clean project and rebuild project. In all modules all classes imports are from the support libraries and used other version libraries excepet AndroidX. Just delete those imports then automatically AndroidX will import those components.

Click on File -> Settings -> Build,Execution,Deployment -> Compiler 

In that command line option I mentioned as --stacktrace for the details log when you build project.

In details, I came to know that few classes still having old imports which are not androidx migrated, so I checked imports for the all the classes.

--Vinod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!