Bug 40156 - Seeing an AAPT error with the latest Build-tools r24 when building projects on Windows that use AppCompat
Summary: Seeing an AAPT error with the latest Build-tools r24 when building projects o...
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: unspecified
Hardware: PC Windows
: High critical
Target Milestone: ---
Assignee: Jonathan Pryor
: 40863 42097 ()
Depends on:
Reported: 2016-04-06 13:04 UTC by Abhishek
Modified: 2017-06-21 23:08 UTC (History)
8 users (show)

Is this bug a regression?: ---
Last known good build:

aapt-bug.zip (5.44 KB, application/zip)
2016-07-05 20:35 UTC, Jonathan Pryor

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Comment 1 Peter Collins 2016-04-06 14:27:00 UTC
I'm able to reproduce this, the issue here is caused by new preview Build-tools (24 rc2). I'm only able to reproduce this issue on Windows, and I can repro from XS, VS and command line:

Diagnostic build output:
Comment 3 Atsushi Eno 2016-04-06 16:30:55 UTC
This suggest to make sure to clean up every related products.

If you could reproduce the error even after fresh reinstallation let us know.
Comment 4 Peter Collins 2016-04-06 18:40:48 UTC
After some further investigation, this seems to only happen for me with projects that reference the AppCompat NuGet. @Abhishek can you confirm? Are you still able to reproduce if you use a base template with no NuGets?
Comment 5 Abhishek 2016-04-06 18:53:58 UTC
If I create the android application with target platforms "modern development" on Windows XS . Then I am successfully able to build and deploy the application on device. 

Screencast: http://www.screencast.com/t/JpB1KcHFYpT0
Build Output: https://gist.github.com/Abhishekk360/a5baad2e08cc583274fe804327994862
Application Output: https://gist.github.com/Abhishekk360/7e4a64ae6385b8db0808351b0d3262e7

But If I create android application with target platforms "Maximum Compatibility" then I am getting the reported behavior.
Comment 7 Peter Collins 2016-05-04 20:40:10 UTC
*** Bug 40863 has been marked as a duplicate of this bug. ***
Comment 8 Peter Collins 2016-06-15 20:53:23 UTC
This is still reproducible using Build tools 24 that were released to the main Android SDK Manager "Tools" channel today.
Comment 9 Peter Collins 2016-07-05 16:28:16 UTC
@Atsushi This reproduces on multiple Windows environments with multiple versions of XA. I am able to reproduce this on a clean VM with no VS installed, and on another machine uninstalling Visual Studio and Xamarin and then re-installing Xamarin does not resolve this issue. 

Jeremie and I recently spent some time trying to debug this further but we were unable to get any additional error logging out of aapt.
Comment 10 Jonathan Pryor 2016-07-05 20:35:38 UTC
Created attachment 16578 [details]
Comment 11 Jonathan Pryor 2016-07-05 20:40:55 UTC
I believe that this is an aapt bug on Windows.

1. Download Attachment #16578 [details]
2. Unzip it
3. Edit aapt-bug\Makefile and edit the filesystem paths as appropriate for your machine.
4. From CMD.EXE, run `NMAKE`:

> Processing image: res\drawable\icon.png
> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Android\android-sdk\build-tools\24.0.0\aapt.exe"' : return code '0xff'
> Stop.

Running on OS X results in no error:

> $ make make AAPT=/opt/android/sdk-tool/sdk/build-tools/24.0.0/aapt \
> ANDROID_JAR=/opt/android/sdk-tool/sdk/platforms/android-23/android.jar
> ...
> Done!

Additionally, it *appears* to be that `aapt` "doesn't like" the Xamarin/Visual Studio-provided Icon.png template file, which differs from all of the Xamarin Studio Icon.png template files. If I replace `res\drawable\icon.png` with the Xamarin Studio `Resources\drawable-hdpi\Icon.png`, `aapt` executes without error.
Comment 12 Peter Collins 2016-07-05 21:19:20 UTC
Logged upstream:

Removing the milestone, and will revisit once there's action on the upstream bug.
Comment 13 Peter Collins 2016-07-18 19:57:15 UTC
Filed upstream as https://code.google.com/p/android/issues/detail?id=215209, and appears to be fixed in build tools 24.0.1.
Comment 14 Brendan Zagaeski (Xamarin Team, assistant) 2017-06-21 23:08:32 UTC
*** Bug 42097 has been marked as a duplicate of this bug. ***