[SOLVED] Error: "Android resource compilation failed"

Anything libgdx related goes here!

[SOLVED] Error: "Android resource compilation failed"

Postby Tekkerue » Wed May 15, 2019 9:39 pm

Hi all, I just started getting this strange compilation error today when trying to run my libgdx project on Android. Both my Android phone and the Android simulator produce this error, but Desktop still works fine.

Error message:
Code: Select all
Android resource compilation failed
...\android\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:17: error: :uiItem>.
...\android\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:18: error: :uiItem>.
...\android\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:19: error: :uiItem>.
...\android\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:20: error: :uiItem>.
...\android\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:21: error: :uiItem>.
...\android\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:22: error: :uiItem>.
...\android\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml: error: file failed to compile.


Lines 17-22 from values.xml:
Code: Select all
<uiItem name="android:windowBackground">@android:color/transparent</uiItem>
<uiItem name="android:colorBackgroundCacheHint">@null</uiItem>
<uiItem name="android:windowAnimationStyle">@android:style/Animation</uiItem>
<uiItem name="android:windowNoTitle">true</uiItem>
<uiItem name="android:windowContentOverlay">@null</uiItem>
<uiItem name="android:windowFullscreen">true</uiItem>


When I open values.xml in Android Studio it displays a message at the top that says "Files under "build" folder are generated and should not be edited."

I've never had an error like this before and I thought it might have been caused by an Android Studio upgrade so I uninstalled it and went back to the previous version, but that didn't fix it. I have also tried renaming the build folder to something else in order to let it recreate the build folder but it still gives the same error.

Any help in getting this solved would be greatly appreciated. Thanks.
Last edited by Tekkerue on Thu May 16, 2019 3:22 am, edited 1 time in total.
Tekkerue
 
Posts: 113
Joined: Sun Aug 24, 2014 10:58 pm

Re: Error: "Android resource compilation failed"

Postby shatterblast » Thu May 16, 2019 12:16 am

I use IntelliJ, which Android Studio tends to follow behind by a couple of versions. If you go to the File menu across the top, you should have an item maybe halfway down in the list that says "Invalidate Caches / Restart ...". This would be the first thing to try. Just as a note on the side, it is okay to delete certain folders as long as your IDE generates them. I think build folders make up one of these, unless you actually name a folder that for whatever odd reason. Of course, you should not delete some necessary folder during the compile process. Also, keeping backups can prove awesome. It just sounds like something corrupted in the cache inside the build folder of your Android module, and both IntelliJ and Android Studio are designed to look at stuff in the cache first to make compiling a bit faster.
shatterblast
 
Posts: 306
Joined: Sun Jul 06, 2014 1:14 pm

Re: Error: "Android resource compilation failed"

Postby Tekkerue » Thu May 16, 2019 1:53 am

Thanks for the reply shatterblast. I just tried "Invalidate Caches / Restart" but that still gives the same error. I then renamed the build folder and tried "Invalidate Caches / Restart" again to let it do a full reset, but that also gives the same error. I tried running a different project and that one works fine on Android, so whatever happened it seems to be isolated to this project. I could create a new libgdx project and move my code over if that seems like the best option to fix this problem.
Tekkerue
 
Posts: 113
Joined: Sun Aug 24, 2014 10:58 pm

Re: Error: "Android resource compilation failed"

Postby shatterblast » Thu May 16, 2019 2:04 am

Considering that neither my project nor a standard setup seem to have a values.xml file, I am not quite sure where to begin.

Edit: Oh wait, it is SYSTEM generated. I still do not have one, though. You could do a ./gradlew clean or similar and re-import your project into Android Studio maybe. By itself, ./gradlew clean could maybe take care of the issue.
shatterblast
 
Posts: 306
Joined: Sun Jul 06, 2014 1:14 pm

Re: Error: "Android resource compilation failed"

Postby Tekkerue » Thu May 16, 2019 3:04 am

After gradlew clean I still get the same error. However, I did find something though, in the values.xml file for my other project that is working and it has <item> tags instead of <uiItem>.

From working project:
Code: Select all
<style name="GdxTheme" parent="android:Theme">
     <item name="android:windowBackground">@android:color/transparent</item>
     <item name="android:colorBackgroundCacheHint">@null</item>
     <item name="android:windowAnimationStyle">@android:style/Animation</item>
     <item name="android:windowNoTitle">true</item>
     <item name="android:windowContentOverlay">@null</item>
     <item name="android:windowFullscreen">true</item>
</style>


From non-working project:
Code: Select all
<style name="GdxTheme" parent="android:Theme">
     <uiItem name="android:windowBackground">@android:color/transparent</uiItem>
     <uiItem name="android:colorBackgroundCacheHint">@null</uiItem>
     <uiItem name="android:windowAnimationStyle">@android:style/Animation</uiItem>
     <uiItem name="android:windowNoTitle">true</uiItem>
     <uiItem name="android:windowContentOverlay">@null</uiItem>
     <uiItem name="android:windowFullscreen">true</uiItem>
</style>


Any idea why those tags would be named differently between the two projects? Both projects were built using the same LibGDX setup file (1.9.8) and this project has been working on Android up until now. Renaming those tags to item might fix the problem, but since it is a generated file I have no idea where to make the change.

Searching google also turned up nothing for this particular problem.
Tekkerue
 
Posts: 113
Joined: Sun Aug 24, 2014 10:58 pm

Re: Error: "Android resource compilation failed"

Postby shatterblast » Thu May 16, 2019 3:10 am

Did you re-import? That would be the last thing in my mind that would indicate whether your source stuff is fine or damaged. Your source material obviously works fine, though, since your Desktop build works. You might try again running the Desktop build, since the cache should have been cleared by now. At the worst, you might indeed have to re-locate your source stuff to a new project setup, but that sounds like something superbly harsh happened if a need even arises for that. If you have to go that far, you might consider updating to LibGDX 1.9.9.
Last edited by shatterblast on Thu May 16, 2019 3:22 am, edited 1 time in total.
shatterblast
 
Posts: 306
Joined: Sun Jul 06, 2014 1:14 pm

Re: Error: "Android resource compilation failed"

Postby Tekkerue » Thu May 16, 2019 3:22 am

I found it! I searched my entire project for "uiItem name" and the uiItem tags are being set in android\res\values\styles.xml
I changed those tags from uiItem to item, so now the valuex.xml file has item tags, and it works on Android again. I have never opened the stiles.xml file before, so I'm not sure how or why that was changed.

Thanks for your help. I'm adding the stuff you gave me to my documents for troubleshooting in the future. :)
Tekkerue
 
Posts: 113
Joined: Sun Aug 24, 2014 10:58 pm

Re: [SOLVED] Error: "Android resource compilation failed"

Postby shatterblast » Thu May 16, 2019 3:22 am

Fantastic! I am glad you got it working.
shatterblast
 
Posts: 306
Joined: Sun Jul 06, 2014 1:14 pm

Re: [SOLVED] Error: "Android resource compilation failed"

Postby Tekkerue » Thu May 16, 2019 4:01 am

Thank you. Me too! I always get more worried about bugs like this that occur outside of my designated coding area, because I don't understand the "magic smoke" that goes on under the hood of LibGDX so I'm essentially flying blind in these cases.
Tekkerue
 
Posts: 113
Joined: Sun Aug 24, 2014 10:58 pm


Return to Libgdx

Who is online

Users browsing this forum: No registered users and 1 guest