Forum Xamarin.Android

'Error MSB4018: The "Aapt" task failed unexpectedly' on new Android Application. No code added.

JohnShaw.9007JohnShaw.9007 USMember
edited May 2013 in Xamarin.Android

Just installed Xamarin. Open Xamarin Studio Create new Android Application. Hit run and get the following error:

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error MSB4018: The "Aapt" task failed unexpectedly.
System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at Xamarin.Android.Tasks.BuildToolsUtils.GetBuildToolsPath(String androidSdkDirectory)
at Xamarin.Android.Tasks.Aapt.GenerateFullPathToTool()
at Microsoft.Build.Utilities.ToolTask.ComputePathToTool()
at Microsoft.Build.Utilities.ToolTask.Execute()
at Xamarin.Android.Tasks.Aapt.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() (MSB4018) (test)

Have looked around on this site and tried a few things but no joy. Any Ideas?

«1

Posts

  • ChrisNelisChrisNelis USMember

    I have just installed the trial today and have also got a very similar error:

    Error 1 The "Aapt" task failed unexpectedly.
    System.InvalidOperationException: Sequence contains no elements
    at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
    at Xamarin.Android.Tasks.BuildToolsUtils.GetBuildToolsPath(String androidSdkDirectory)
    at Xamarin.Android.Tasks.Aapt.GenerateFullPathToTool()
    at Microsoft.Build.Utilities.ToolTask.ComputePathToTool()
    at Microsoft.Build.Utilities.ToolTask.Execute()
    at Xamarin.Android.Tasks.Aapt.Execute()
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() AndroidApplication1

  • ChrisNelisChrisNelis USMember

    Update:

    Fixed my issue by opening the Android SDK Manager and installing the packages that were available.

    Not sure if this is the correct response, but it was a iffy SDK install that was causing my issue.

    The Android path was C:\Users\USERNAME\AppData\Local\Android

    Which I'm not 100% would be the default location, perhaps the installer is putting it in there?

  • I also have this error, it worries me that there are not offical answers to this kind og bug.

  • jeyaramanjeyaraman USMember

    I am also facing the same problem..... Pls reply me as soon as possible... Thanks in advance

  • vikram.2579vikram.2579 INUniversity ✭✭

    Even i got the same Error but fixed it by opening the Android SDK Manager and updating the Android SDK platform-tools under tools sections.

  • How does one update the Android SDK platform-tools under tools section? I se no possibility to update?

  • I am glad I am only trying out this software and have not bought it yet. Never seems to work.

  • I solved the problem by going into the directory: C:\Users\Christian\AppData\Local\Android\android-sdk
    and doubleclicked the sdk manager.exe. this UI showed that there 12 packages for installation i installed these.

  • NikdeMothNikdeMoth BYMember

    AlvinStraight, thank you

  • chandansonichandansoni USMember

    I have just installed the trial today and have also got a very similar error:

    C:\Program Files\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error MSB4018: The "Aapt" task failed unexpectedly.

    System.InvalidOperationException: Sequence contains no elements

    at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)

    at Xamarin.Android.Tasks.BuildToolsUtils.GetBuildToolsPath(String androidSdkDirectory)

    at Xamarin.Android.Tasks.Aapt.GenerateFullPathToTool()

    at Microsoft.Build.Utilities.ToolTask.ComputePathToTool()

    at Microsoft.Build.Utilities.ToolTask.Execute()

    at Xamarin.Android.Tasks.Aapt.Execute()

    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

    at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() (MSB4018) (Hello_World)

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    I have just installed the trial today and have also got a very similar error:

    You have a $ANDROID_SDK_PATH/build-tools directory, but there is nothing inside of it. Please install the Android SDK Build-tools package.

  • russd2357russd2357 USMember

    I reinstalled the build tools (at least I think I did) but still not working. I also downloaded the trial version (4.0.8)

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    Can you provide diagnostic build output?

  • russd2357russd2357 USMember
    edited May 2013

    Here it is:

    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error MSB4018: The "Aapt" task failed unexpectedly.
    System.InvalidOperationException: Sequence contains no elements
       at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
       at Xamarin.Android.Tasks.BuildToolsUtils.GetBuildToolsPath(String androidSdkDirectory)
       at Xamarin.Android.Tasks.Aapt.GenerateFullPathToTool()
       at Microsoft.Build.Utilities.ToolTask.ComputePathToTool()
       at Microsoft.Build.Utilities.ToolTask.Execute()
       at Xamarin.Android.Tasks.Aapt.Execute()
       at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
       at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() (MSB4018) (TaskyAndroid)
    
  • benhorgenbenhorgen USMember ✭✭

    I was receiving the compiler exception that russd2357 posted.

    I heeded the advice above from: Chris Nelis, Christian Andersen, and Alvin Straight and updated the 'Android SDK build-tools'. There advice resolved my issue immediately.

    To resolve the error, your dev environment needs to be running Android SKD Build-tools, Rev 17. Updating to Rev 17 is easy to overlook because it appears to occur over a two-part install, via the SDK Manager. The first update via the SDK Manager will update several packages but only after that first update completes does the Android SDK build-tools Rev 17 become available for update through the SDK Manager.

    Got questions, tweet me: @benhorgen

  • YuriShteinmanYuriShteinman CAUniversity ✭✭
    edited May 2013

    I have build-toold version 17 (looks like latest) installed. When I build the project I get in XS:
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error XA5205: Cannot find aapt. Please install the Android SDK Build-tools package with the C:\Users\yuris\AppData\Local\Android\android-sdk/android program. (XA5205) (AdnroidApp3)

  • russd2357russd2357 USMember

    Yes, I have build tools v. 17 as well. I'm sure it's probably something really basic that I'm missing.

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    @YuriShteinman: You're using the latest alpha release on Windows, which had no QA, and (unfortunately) had a regression in that area. It will be fixed in 4.7.6.

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    @russd2357: Unfortunately, I don't know what's wrong on your machine. Does $(AndroidSdkDirectory)\build-tools\17.0.0\aapt.exe (e.g. C:\Users\USER_NAME\AppData\Local\Android\android-sdk\build-tools\17.0.0\aapt.exe) exist?

    Do you have more than one Android SDK installed? Is Xamarin Studio/Visual Studio referring to the right one?

  • russd2357russd2357 USMember

    That was exactly what the problem was! I had installed another Android sdk before i got Xamarin Studio, and the SDK Manager shortcut i was using pointed to the wrong one. When i launched the correct one and installed the build tools from there, i was good to go. Thanks! Like i guessed, it was something simple

  • YuriShteinmanYuriShteinman CAUniversity ✭✭

    @jonp The update to alpha was suggested by your support trying to fix another bug. Your guys should be more careful with their advices. Now I have to spend half day rolling everything back to 4.6 Do you have an estimation when 4.7.6 is going to be available?

  • sridarmsridarm USMember

    I had the similar issue exactly with the same error message but for the first time the application was built successfully when there were no emulators, when I created a new emulator to test the application then I saw this error tying to build.

    As suggested I have installed the 12 packages (it will take some time but you have to wait) error disappeared.

    One issue is when you try to debug applications, start your emulators first, if it is first time there studio will do another silent installation while compiling, so be patient.

    After those glitches, I am a happy developer.

  • CraigSchulteCraigSchulte USMember

    I just started experiencing this error too and it is very random! please help

  • CraigSchulteCraigSchulte USMember

    updating the android tools fixed this for me

  • Got the same error as you guys!!!

    C:\Program Files\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(3,3): Error MSB4018: The "Aapt" task failed unexpectedly.

    System.InvalidOperationException: Sequence contains no elements

    at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)

    at Xamarin.Android.Tasks.BuildToolsUtils.GetBuildToolsPath(String androidSdkDirectory)

    at Xamarin.Android.Tasks.Aapt.GenerateFullPathToTool()

    at Microsoft.Build.Utilities.ToolTask.ComputePathToTool()

    at Microsoft.Build.Utilities.ToolTask.Execute()

    at Xamarin.Android.Tasks.Aapt.Execute()

    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

    at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() (MSB4018) (SNMPGet)

    I followed jonp advice and updated my Android SDK Platform tools and it worked fine!

    I'm realizing that it only worked because it is pointing to API 17 and I didn't had my SDK updated.

    Just one thing. Does this mean that we have to work with API 17? Thanks!

  • LucasPUaoijLucasPUaoij BRMember

    to me too

  • Ark-kunArk-kun RUMember

    Your code in [Xamarin.Android.Build.Tasks]Xamarin.Android.Tasks.ResolveSdks.Execute() is wrong. You look for a file named "aapt" while on Windows the file is called "aapt.exe".

    P.S. What does "Please install the Android SDK Build-tools package with the SdkPath/android program." even mean?

  • JulianNischlerJulianNischler ATMember
    edited May 2013

    As Ark-kun mentioned the code has a bug.
    And yes the error is kind of funny .. ;)

    if (Directory.Exists(str) && File.Exists(Path.Combine(str, "aapt")))

    But the file is called aapt.exe

    Create a copy of your aapt.exe named aapt.

    The file should be located in:

    android-sdk\build-tools\17.0.0

    This worked for me!

    Edit:
    I also needed to copy my java.exe to android-sdk\build-tools\17.0.0

  • BhuwanBhuwan USMember

    Dear Friends

    I also got the same problem which is as below

    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error MSB4018: The "Aapt" task failed unexpectedly.

    System.InvalidOperationException: Sequence contains no elements

    at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)

    at Xamarin.Android.Tasks.BuildToolsUtils.GetBuildToolsPath(String androidSdkDirectory)

    at Xamarin.Android.Tasks.Aapt.GenerateFullPathToTool()

    at Microsoft.Build.Utilities.ToolTask.ComputePathToTool()

    at Microsoft.Build.Utilities.ToolTask.Execute()

    at Xamarin.Android.Tasks.Aapt.Execute()

    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

    at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() (MSB4018) (Hello_World)

    Please help if anyone of you have solve the issue

  • BhuwanBhuwan USMember

    I just opened Android SDK manager and found that there are 13 install packages are pending, installing those packages, let see what will happen after that...will update after this

  • MiladMilad USMember ✭✭

    I updated my sdk manager and worked.
    i suggest do that.

  • This Solved my Issue:

    AS POSTED BY: AlvinStraight

    1.Launch Android SDK Manager •click on Start button -> All programs -> Android SDK Tools -> SDK Manager
    •OR run "C:\Users\YOUR_USERNAME\AppData\Local\Android\android-sdk\SDK Manager.exe"

    2.Install package "Android SDK Build-tools". It is not necessary to install other packages.

  • ManasParhiManasParhi USMember

    I just installed Xamerine on top of VS 2010 and I am facing the same issue when trying to build the app.
    Error 1 The "Aapt" task failed unexpectedly.
    System.InvalidOperationException: Sequence contains no elements
    at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
    at Xamarin.Android.Tasks.BuildToolsUtils.GetBuildToolsPath(String androidSdkDirectory)
    at Xamarin.Android.Tasks.Aapt.GenerateFullPathToTool()
    at Microsoft.Build.Utilities.ToolTask.ComputePathToTool()
    at Microsoft.Build.Utilities.ToolTask.Execute()
    at Xamarin.Android.Tasks.Aapt.Execute()
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() AndroidTestApp

    Even I don't find the path C:\Users\USER_NAME\AppData\Local\Android\android-sdk as mentioned in this thread to do any update. Please suggest.

  • StevenTheEvenStevenTheEven SEMember ✭✭✭

    1.Launch Android SDK Manager •click on Start button -> All programs -> Android SDK Tools -> SDK Manager

  • BjarkeBjarke USMember ✭✭

    Hey Guys, I experienced the same issue. I was working on our app, everything was working fine. I started the android monitor because I wanted to check some memory use and then hell broke loose and I got the appt error.
    I solved it by updating the sdk tools, platform tools and build tools as suggested.

  • LaliteshKumarLaliteshKumar USMember

    You need to set anroid SDk path in options. I did and compiled it worked

  • TonyBorfTonyBorf USMember

    I had the same issue, I had to add a proxy setting in SDK manager so It would download. After that it ran fine.

  • FreakyAliFreakyAli USMember ✭✭

    Had the same issue solved it my reverting my Manifest. The problem a space between the application level xml and android keyword

Sign In or Register to comment.