Bug 24488 - aapt.exe crashes
Summary: aapt.exe crashes
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.20.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-11-13 05:30 UTC by Miha Markic
Modified: 2014-11-14 02:33 UTC (History)
1 user (show)

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

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:
Status:
RESOLVED FIXED

Description Miha Markic 2014-11-13 05:30:53 UTC
When referencing Syncfusion.SfChart.Android.dll (Syncfusion Xamarin suite) the aapt.exe keeps crashing with output like 

>  D:\Android\android-sdk\build-tools\21.0.0\aapt.exe package -f -m -M C:\Users\XXX\AppData\Local\Temp\4jbsneqj.11v\AndroidManifest.xml -J C:\Users\XXX\AppData\Local\Temp\4jbsneqj.11v --custom-package app4.app4 -F C:\Users\XXX\AppData\Local\Temp\4jbsneqj.11v\resources.apk.bk -S obj\Debug\res -S G:\Temp\TempProjects\App4\App4\obj\Debug\__library_projects__\Syncfusion.SfChart.Android\library_project_imports\res -j obj\Debug\__library_projects__\Syncfusion.SfChart.Android\library_project_imports\bin\SfChart.Android.jar -I D:\Android\android-sdk\platforms\android-21\android.jar --extra-packages com.syncfusion.widget.chart --auto-add-overlay 
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(794,2): error MSB6006: "aapt.exe" exited with code -1073741819.

It is probably jar related error not specific to Syncfusion, but who knows. It happens with both Xamarin IDE and Visual Studio.
To repro just create a blank Android project and reference mentioned assembly. VS will start reporting aapt crashes...

Xamarin.Android
Version: 4.20.0 (Business Edition)
Android SDK: D:\Android\android-sdk
	Supported Android versions:
		4.0.3  (API level 15)
		4.4.87 (API level 20)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)
Comment 1 Miha Markic 2014-11-13 08:48:55 UTC
I tested with latest stable and I am experiencing the same aapt crash. The only thing that recently changed was beta update (that I can think of). With previous beta it was working. Can I get the previous beta to double check it?
Comment 2 Jonathan Pryor 2014-11-13 16:49:57 UTC
What's probably happening is you've updated the Android SDK build-tools, which updated  `aapt`, and `aapt` is not reporting new errors. (One I ran across: aapt now reports an error if you have an <activity/> without an android:name attribute.)

Please enable diagnostic build output, and (hopefully) that'll dump all the output that aapt emits. If that doesn't work...then we'll need to hack up Xamarin.Android.Common.targets to preserve those temp directories so that you can run the aapt command manually...
Comment 3 Miha Markic 2014-11-13 17:01:12 UTC
Hi Jonathan,

Diagnostics doesn't help. I've updated SDK but only after this error started (I think).
From the path I see that aapt v21 is used. Is there a setting that would use lower version?
Anyway, I am ready to hack that target.
Comment 4 Jonathan Pryor 2014-11-13 22:38:10 UTC
@Miha: At the end of the _UpdateAndroidResgen target is a call to <RemoveDirFixed/>. REMOVE IT.

In Xamarin.Android 4.20, this is line 850:

	<!-- Delete our temporary directory -->
	<RemoveDirFixed Directories="$(ResgenTemporaryDirectory)" />

After removing it, rebuild your app. You will (again) see the `aapt` command, but now the directory it's referring to will still exist. Copy the entire `aapt` command and run it manually from CMD.EXE.

If you're lucky, you will see additional output that may provide a hint as to what's going wrong.
Comment 5 Jonathan Pryor 2014-11-13 22:39:14 UTC
Note: The file to edit is:

%ProgramFiles(x86)%\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets
Comment 6 Miha Markic 2014-11-14 02:26:00 UTC
OK, solved the issue. The problem was, that I was using build-tools v21.0.0. Once I've installed 21.1.1 the problem went away. I assume Xamarin uses the latest if more than one version is installed.

As per diaagnostics. I've removed the <RemoveDirFixed /> node and was able to run it from command line. At least now is clear why there was no error output - aapt 21.0.0. simply crashes without any output whatsoever.