Bug 61071 - Library with CPS and support libraries fails to rebuild randomly
Summary: Library with CPS and support libraries fails to rebuild randomly
Status: NEW
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: 4.8.0 (15.5)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-12-11 14:44 UTC by Matthias
Modified: 2017-12-21 17:54 UTC (History)
5 users (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 for Bug 61071 on Developer Community 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
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.
Related Links:
Status:
NEW

Description Matthias 2017-12-11 14:44:10 UTC
We are trying to use android libraries in the new common project system with the help of the MSBuild.Sdk.Extras. So far it worked well but since we are referencing more support libraries rebuilds randomly threw errors and fail.

The project file is as follows:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
  <PropertyGroup>
    <TargetFramework>monoandroid80</TargetFramework>
    <RootNamespace>Framework</RootNamespace>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="MSBuild.Sdk.Extras" Version="1.1.0" PrivateAssets="All" />
    <PackageReference Include="Xamarin.Android.Support.v4" Version="26.1.0.1" />
    <PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="26.1.0.1" />
  </ItemGroup>
  <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
</Project>

The environment is as follows:

Microsoft Visual Studio Professional 2017 
Version 15.5.0
VisualStudio.15.Release/15.5.0+27130.0
Microsoft .NET Framework
Version 4.6.01586

VisualStudio.Mac   1.0
Xamarin   4.8.0.752 (4a1f0ea)
Xamarin Designer   4.8.182 (76aa1723e)
Xamarin.Android SDK   8.1.0.24 (HEAD/9cfa7836b)
Xamarin.iOS and Xamarin.Mac SDK   11.4.0.214 (c4240f3)

The rebuild randomly fails with one of the following errors in the output window:

Error	MSB4018	The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.DirectoryNotFoundException: Could not find a part of the path '...\obj\Debug\monoandroid80\lp\12'.
OR
Error	MSB4018	The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.IOException: The process cannot access the file '...\obj\Debug\monoandroid80\lp\5\__AndroidLibraryProjects__.zip' because it is being used by another process.

The exact folder/file is changing but it's always not found or access denied.

At the same time VisualStudio shows an additional error that is not present in the build output:

Error	MSB4018	The "GetImportedLibraries" task failed unexpectedly.
System.IO.DirectoryNotFoundException: Could not find a part of the path '...\obj\Debug\monoandroid80\designtime\libraryimports.cache'.

With the help of the project system tools you can see that every Rebuild is doing a DesignTime build at the same (no clue if that should be done at all) and they try to work on the same files and block each other out.
We can't reproduce the error on every rebuild but usually after some rebuilds it's happening.
MSBuild on the command line works fine (because it's not doing DesignTime builds I guess).
Comment 1 mailcannon 2017-12-20 05:08:26 UTC
same issue here. different taste. when rebuilding android project it rebuilds successfully but apk is broken and cannon launch on phone. Sometimes i can build apk that launches but randomly crashes with 
"java.lang.ClassNotFoundException: Didn't find class"
exceptions for different classes for every rebuild. 

msbuild seems working fine
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2017-12-20 20:53:26 UTC
(In reply to mailcannon from comment #1)
> same issue here. different taste. when rebuilding android project it
> rebuilds successfully but apk is broken and cannon launch on phone.
> Sometimes i can build apk that launches but randomly crashes with 
> "java.lang.ClassNotFoundException: Didn't find class"
> exceptions for different classes for every rebuild. 

That sounds more like Bug 61073.  I would recommend following that other bug report for updates on that ClassNotFoundException issue.
Comment 3 mailcannon 2017-12-21 07:19:59 UTC
not sure if you're right or not. msbuild workarround helped me, I have files being used by another process in my bin and obj folders and i don't have incremental assembly builds as described by some people in 61073.
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2017-12-21 17:54:20 UTC
At the least, Comment 0 on this bug report doesn't mention `ClassNotFoundException` at all.  All the errors from Comment 0 happen at build time, whereas the description from Comment 1 indicates that the build succeeds (albeit incorrectly) _without_ error, and then the app fails at _run time_ with the `ClassNotFoundException`.  Additionally, the description in Comment 0 indicates that the "new" thing that the original reporter is doing is using the "the new common project system," whereas as you noticed in Bug 61073, Comment 32, for the issue you've observed in Comment 1, the "new" thing that's surfacing an error is an update in Xamarin versions.  Those details sound different from Comment 0.  So if you think you're seeing something other than Bug 61073, then I would recommend filing a new bug report.  Thanks!