Bug 30571 - MSBuild and Xbuild bug with /p:AndroidManifest params when building dependent library
Summary: MSBuild and Xbuild bug with /p:AndroidManifest params when building dependent...
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 5.2
Hardware: All All
: High normal
Target Milestone: ---
Assignee: dean.ellis
Depends on:
Reported: 2015-05-29 04:28 UTC by Romain Flechner
Modified: 2017-02-21 13:58 UTC (History)
5 users (show)

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 for Bug 30571 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Romain Flechner 2015-05-29 04:28:37 UTC

Please find in attached zip file ( at URL http://statics.romcyber.com/BuildTestApp.zip ) an example of projects reproducing the bug.

The problem occurs when we add a library to a project.

(_ValidateAndroidPackageProperties target) -> C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(411,2): error : AndroidManifest file does not exist [C:\Users\romain.flechner\Documents\Projects\BuildTestApp\BuildTestApp.Lib\BuildTestApp.Lib.fsproj]

You can try with commands in build.txt included in zip file.

MSBuild.exe BuildTestApp.fsproj /t:PackageForAndroid /m /p:RestorePackages="False" /p:OutputPath="C:\Users\romain.flechner\Documents\Projects\BuildTestApp\build" /p:Configuration="Release" /p:AndroidManifest="Properties\AndroidManifest.armeabi-v7a.xml" /p:AndroidSupportedAbis="armeabi-v7a"

Change the output path in command line.

When I remove the library project, the build works

We found a solution:

Xamarin.Android.Common.targets has a bug.

replace line 408
<CreateProperty Value="$(ProjectDir)$(AndroidManifest)" Condition="'$(AndroidManifest)' != ''">

by <CreateProperty Value="$(ProjectDir)$(AndroidManifest)" Condition="'$(AndroidManifest)' != '' And '$(AndroidApplication)' ==True">

Can you integrate this fix in a next release of Xamarin ?
Comment 1 Romain Flechner 2015-07-07 09:48:26 UTC

I read the documentation explaining how to build ABI specific apks:

The documentation suggested to use Rake or Fake (http://fsharp.github.io/FAKE/)

So I developed a Fake module to script ABI specific apks builds.

You can see my fork here: https://github.com/rflechner/FAKE/commits/AbiSpecific

I am waiting for the fix of Xamarin.Android.Common.targets to create a pull request.

Should it be possible to check the quick fix I proposed 6 weeks ago or just have a reply ?

Comment 2 dean.ellis 2015-07-07 13:44:51 UTC
Hi Romain

I'll take a look at this issue for you, I have managed to replicate the problem using the test project attached. I'm not 100% sure at the moment that your suggested fix will have any knock on side effects on Library projects, but I will investigate and see if we can find a solution.

In the mean time a work around would be to place the definitions for the AndroidManifest into the cs/fsproj file like so 

<AndroidManifest Condition=" '$(AndroidSupportedAbis)' == 'armeabi-v7a''">Properties\AndroidManifest.armeabi-v7a.xml</AndroidManifest>
<AndroidManifest Condition=" '$(AndroidManifest)' == ''">Properties\AndroidManifest.xml</AndroidManifest>

You can see I'm using conditionals to pick the right Manifest File. Note you can also use the following style of conditional as well

Condition=" ($(AndroidSupportedAbis.Contains('arm64-v8a')) Or $(AndroidSupportedAbis.Contains('x86_64')))"

This works on both msbuild and xbuild.

Then you can just setup your build system to pass in the 


parameter for each type of supported abi you are after.
Comment 3 Romain Flechner 2015-09-22 05:40:45 UTC

The inconvenience of this solution is I have to rewrite the fsproj to add the conditions.

I think FAKE don't have to modify fsproj.

I can try to rewrite the original AndroidManifest directly for each build and rollback it after, but I find it a little hazardous.

Comment 4 Romain Flechner 2015-10-13 04:06:29 UTC
For your information, my pull request with this solution is merged: