Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WorkManager fails to compile on version 9.4 #3343

Closed
jschmid opened this issue Jul 10, 2019 · 9 comments · Fixed by #3362
Closed

WorkManager fails to compile on version 9.4 #3343

jschmid opened this issue Jul 10, 2019 · 9 comments · Fixed by #3362
Labels
regression vs-sync For internal use only; creates a VSTS "mirror" issue.
Milestone

Comments

@jschmid
Copy link

jschmid commented Jul 10, 2019

Steps to Reproduce

  1. Checkout https://github.com/jschmid/WorkManagerCompilation
  2. Try to compile

Expected Behavior

Project compiles, like on Xamarin.Android 9.3.

Actual Behavior

Compilation error:

Target _CompileJava:
    Directory "obj/Debug/android/bin/classes" doesn't exist. Skipping.
    /Users/jonas/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25/bin/javac -J-Dfile.encoding=UTF8 -d obj/Debug/android/bin/classes -classpath /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v9.0/mono.android.jar:/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/java_runtime_fastdev.jar:obj/Debug/lp/0/jl/formsviewgroup.jar:obj/Debug/lp/1/jl/android.arch.core.common.jar:obj/Debug/lp/10/jl/bin/classes.jar:obj/Debug/lp/11/jl/com.android.support.collections.jar:obj/Debug/lp/12/jl/bin/classes.jar:obj/Debug/lp/13/jl/bin/classes.jar:obj/Debug/lp/14/jl/bin/classes.jar:obj/Debug/lp/15/jl/bin/classes.jar:obj/Debug/lp/16/jl/bin/classes.jar:obj/Debug/lp/17/jl/bin/classes.jar:obj/Debug/lp/18/jl/bin/classes.jar:obj/Debug/lp/19/jl/bin/classes.jar:obj/Debug/lp/2/jl/bin/classes.jar:obj/Debug/lp/20/jl/bin/classes.jar:obj/Debug/lp/21/jl/bin/classes.jar:obj/Debug/lp/22/jl/bin/classes.jar:obj/Debug/lp/23/jl/bin/classes.jar:obj/Debug/lp/24/jl/bin/classes.jar:obj/Debug/lp/25/jl/bin/classes.jar:obj/Debug/lp/26/jl/bin/classes.jar:obj/Debug/lp/27/jl/bin/classes.jar:obj/Debug/lp/28/jl/bin/classes.jar:obj/Debug/lp/29/jl/bin/classes.jar:obj/Debug/lp/3/jl/android.arch.lifecycle.common.jar:obj/Debug/lp/30/jl/bin/classes.jar:obj/Debug/lp/32/jl/bin/classes.jar:obj/Debug/lp/33/jl/bin/classes.jar:obj/Debug/lp/34/jl/bin/classes.jar:obj/Debug/lp/35/jl/bin/classes.jar:obj/Debug/lp/36/jl/bin/classes.jar:obj/Debug/lp/37/jl/bin/classes.jar:obj/Debug/lp/38/jl/bin/classes.jar:obj/Debug/lp/39/jl/bin/classes.jar:obj/Debug/lp/4/jl/bin/classes.jar:obj/Debug/lp/43/jl/bin/classes.jar:obj/Debug/lp/44/jl/bin/classes.jar:obj/Debug/lp/45/jl/bin/classes.jar:obj/Debug/lp/46/jl/common.jar:obj/Debug/lp/47/jl/bin/classes.jar:obj/Debug/lp/48/jl/bin/classes.jar:obj/Debug/lp/5/jl/bin/classes.jar:obj/Debug/lp/6/jl/bin/classes.jar:obj/Debug/lp/7/jl/bin/classes.jar:obj/Debug/lp/8/jl/bin/classes.jar:obj/Debug/lp/9/jl/com.android.support.support-annotations.jar -bootclasspath /Users/jonas/Library/Android/sdk/platforms/android-28/android.jar -encoding UTF-8 "@/var/folders/c8/w1k_9css1p17lw9288pp0bfw0000gn/T/tmp19026bba.tmp" 
    obj/Debug/android/src/md59c73ed0f6f0816547049fec1b3c815af/CalculatorWorker.java:4: error: cannot access ListenableFuture
    public class CalculatorWorker
           ^
      class file for com.google.common.util.concurrent.ListenableFuture not found
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    1 error
    obj/Debug/android/src/md59c73ed0f6f0816547049fec1b3c815af/CalculatorWorker.java(4,8): error :  error: cannot access ListenableFuture
    obj/Debug/android/src/md59c73ed0f6f0816547049fec1b3c815af/CalculatorWorker.java(4,8): error : public class CalculatorWorker
    obj/Debug/android/src/md59c73ed0f6f0816547049fec1b3c815af/CalculatorWorker.java(4,8): error :   class file for com.google.common.util.concurrent.ListenableFuture not found
    obj/Debug/android/src/md59c73ed0f6f0816547049fec1b3c815af/CalculatorWorker.java(4,8): error : 
Done building target "_CompileJava" in project "WorkManagerCompilation.Android.csproj" -- FAILED.

Done building project "WorkManagerCompilation.Android.csproj" -- FAILED.

Build FAILED.

Version Information

From Visual Studio for Mac === Visual Studio Community 2019 for Mac ===

Version 8.1.5 (build 9)
Installation UUID: c1e57dbd-db6c-4e43-9f30-8df655acc4c6
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.6.0.25 (d16-0 / 50f75273)

Package version: 518010028

=== Mono Framework MDK ===

Runtime:
Mono 5.18.1.28 (2018-08/223ea7ef92e) (64-bit)
Package version: 518010028

=== NuGet ===

Version: 5.0.2.5988

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.2.5
2.1.8
2.1.2
2.0.5
2.0.0
SDK: /usr/local/share/dotnet/sdk/2.2.300/Sdks
SDK Versions:
2.2.300
2.2.107
2.1.504
2.1.302
2.1.4
2.0.0
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.18.1/lib/mono/msbuild/Current/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.10
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 9.4.0.34 (Visual Studio Community)
Commit: xamarin-android/d16-2/7cce305
Android SDK: /Users/jonas/Library/Android/sdk
Supported Android versions:
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.1
SDK Build Tools Version: 29.0.0 rc1

Build Information:
Mono: mono/mono@c6edaa62f94
Java.Interop: xamarin/java.interop/d16-2@b2b2610
LibZipSharp: grendello/LibZipSharp/d16-2@caa0c74
LibZip: nih-at/libzip@b95cf3f
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/master@4f717b6

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/jonas/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android Device Manager ===

Version: 1.2.0.44
Hash: aac645b
Branch: remotes/origin/d16-1
Build date: 2019-05-29 19:55:24 UTC

=== Xamarin Designer ===

Version: 16.1.0.467
Hash: f1657e133
Branch: remotes/origin/d16-1-new-document-model
Build date: 2019-06-18 21:57:42 UTC

=== Apple Developer Tools ===

Xcode 10.2 (14490.120)
Build 10E125

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 12.10.0.157 (Visual Studio Community)
Hash: 6bd94753
Branch: d16-1
Build date: 2019-06-12 17:28:47-0400

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 801050009
Git revision: bd0ab28ba941b19b39322247db020dcd0fb305d0
Build date: 2019-07-03 17:15:21+00
Build branch: release-8.1
Xamarin extensions: 8cc25b5cb090e6c23b62a7901000c299977eb08d

=== Operating System ===

Mac OS X 10.14.5
Darwin 18.6.0 Darwin Kernel Version 18.6.0
Thu Apr 25 23:16:27 PDT 2019
root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

Fun stuff, if you:

  • Compile using version 9.3.0.23
  • Quit Visual Studio
  • Install 9.4.0.34
  • Open the projet and run

It will work. But that's not very practical. ¯_(ツ)_/¯

VS bug #948417

@jonathanpeppers
Copy link
Member

jonathanpeppers commented Jul 15, 2019

The problem is this Xamarin.Google.Guava.ListenableFuture.dll assembly does not seem to have any markers that show this is a Xamarin.Android assembly:

image

This assembly contains no C# code. It does not have a TargetFrameworkIdentifier of MonoAndroid or reference Mono.Android.dll.

We have a performance improvement in 16.1 that is breaking this... This DLL appears it just includes a guava-listenablefuture.jar EmbeddedResource file that makes _CompileJava work. But it is not even a Xamarin.Android assembly?!?

I will need to research what we should do about projects like this:

https://github.com/xamarin/XamarinComponents/blob/54646f5c0bef9c618c700628bd1167768d7c9b4f/Android/Guava/source/Guava.ListenableFuture/Guava.ListenableFuture.csproj

@jonathanpeppers
Copy link
Member

Ok, this seems like a very obscure MSBuild bug...

If I added an empty, Properties\AssemblyInfo.cs to this Xamarin.Google.Guava.ListenableFuture project, then the [assembly: TargetFramework] attribute appears...

Then I reviewed parts of MSBuild that do this:

    <ItemGroup Condition="'@(Compile)' != '' and '$(TargetFrameworkMonikerAssemblyAttributeText)' != ''">
      <Compile Include="$(TargetFrameworkMonikerAssemblyAttributesPath)"/>
      <!-- Do not put in FileWrites: this is a file shared between projects in %temp%, and cleaning it would create a race between projects during rebuild -->
    </ItemGroup>

In this Xamarin.Google.Guava.ListenableFuture project, the <Compile/> item group is completely empty. When I add a @(Compile) item of any kind the [assembly:TargetFramework] appears in the output assembly.

A workaround for this project might also be to set <TargetFrameworkMonikerAssemblyAttributeText>, so I'll see about sending a PR to XamarinComponents to fix this. I also need to see if there is a workaround for the current problem in the Xamarin.Android project that consumes this NuGet package.

jonathanpeppers added a commit to jonathanpeppers/XamarinComponents that referenced this issue Jul 16, 2019
Fixes: dotnet/android#3343
Context: dotnet/android#3343 (comment)
Context: dotnet/android#2934

In Visual Studio 2019 16.1, we added some performance improvements in
Xamarin.Android.

In cases of .NET assemblies that:

* Do not have `[assembly: TargetFramework ("MonoAndroid")]`
* Have no reference to `Mono.Android.dll`

Unfortunately, these two Guava projects fit into this category! They
include `<EmbeddedJar/>` but otherwise have no markings at all that
would indicate they are Xamarin.Android assemblies.

Reading the source code for MSBuild, I found that including a single
`@(Compile)` item solves the issue:

https://github.com/microsoft/msbuild/blob/0cd0e92a7243088977d31b56626b56d6116de016/src/Tasks/Microsoft.Common.CurrentVersion.targets#L3341-L3344

    <ItemGroup Condition="'@(Compile)' != '' and '$(TargetFrameworkMonikerAssemblyAttributeText)' != ''">
      <Compile Include="$(TargetFrameworkMonikerAssemblyAttributesPath)"/>
    </ItemGroup>

As soon as I added an empty `*.cs` file to the projects,
`[assembly:TargetFramework]` appeared in the output assembly with the
necessary info.

This must be a weird corner case for MSBuild... I am not sure if there
is anything we can do on the Xamarin.Android side yet.
@jonpryor jonpryor modified the milestones: d16-3, d16-2 Jul 17, 2019
@jonpryor jonpryor added the vs-sync For internal use only; creates a VSTS "mirror" issue. label Jul 17, 2019
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Jul 17, 2019
…r files

Fixes: dotnet#3343
Context: https://github.com/xamarin/XamarinComponents/blob/54646f5c0bef9c618c700628bd1167768d7c9b4f/Android/Guava/source/Guava.ListenableFuture/Guava.ListenableFuture.csproj

We introduced a performance improvement in 5ec3e3a that "classifies"
assemblies as Xamarin.Android assemblies or not. This allows us to
skip processing of NetStandard/BCL assemblies throughout the build.

Unfortunately, this Guava.ListenableFuture assembly is odd:

* No `[assembly: TargetFramework]` attribute at all
* No reference to `Mono.Android.dll`

The only "marker" is that it has a `.jar` file as an
`EmbeddedResource`, which is put there by `<EmbeddedJar/>`. Its
weirdness is related to it not having any C# code, and using SDK-style
projects.

The fix here is to update `<FilterAssemblies/>` to look for:

* `[assembly: TargetFramework("MonoAndroid,Version=v9.0")]`
* `Mono.Android.dll` reference
* `EmbeddedResource` ending with `*.jar`
* `EmbeddedResource` beginning with `__Android`

I also reworked this task so that the logic is hardcoded. It does not
seem useful to pass in input parameters from MSBuild targets anymore.
jonpryor pushed a commit that referenced this issue Jul 17, 2019
The current release note process involves reading the `git log`
output to determine which bugs were fixed, which features were added,
and any other relevant information.

This is error prone: bug fixes are easy enough -- look for `Fixed:`
and copy the URL -- but "features" are often not necessarily
considered as "features" during authorship ("it fixes a corner case")
and *semantic* changes may be overlooked (e.g. Issue #3343, caused by
commit 5ec3e3a, which was an optimization).

Attempt to reduce the "error prone"-ness of the release note process
by adding a new `Documentation/release-notes/master.md` to the repo.

All Pull Requests which fix a user-facing bug, implement a user-facing
feature, *intentionally* alter semantics, etc., should *also* update
`Documentation/release-notes/master.md` with a description of the
change.

The "editorial audience" of `master.md` is end-users of the product.
(Meanwhile, the "audience" of commit messages is other developers
of the xamarin-android repo.  These are not the same folks!)

If the change to `master.md` uses images, the images shall be added
to `Documentation/release-notes/images/`.

Authors of new fixes and improvements don't need to do anything
special if their changes get cherry-picked from `master` to a release
branch.  The team members who handle final release notes preparation
and publication will copy or move notes as needed from `master.md` to
earlier releases for changes that get cherry-picked.

The `master.md` template follows the same section order as the
[final published release notes][0], but it omits a few details like
release dates that aren't needed in the draft format.

The final notes also follow the text formatting rules described in
the [xamarin-docs contribution guidelines][1].  The draft notes don't
need to follow those guidelines too strictly.  For example, it's fine
to use backticks around paths in these draft notes rather than
italics.  That makes it easier to avoid unintentional formatting
issues when paths include characters like `_` or `*`.

Similarly, there's no need to worry about list indentation or line
wrapping in these draft notes.  Authors can optionally wrap lines to
80 characters and indent list items to match the example items, but
it's not required.

As part of branching for a new release, the current `master.md` file
will be renamed to match the new release branch name, and a new empty
template `master.md` file will be added by copying the original template
from this commit and updating the version numbers.

[0]: https://docs.microsoft.com/xamarin/android/release-notes/
[1]: https://github.com/MicrosoftDocs/xamarin-docs/blob/live/contributing-guidelines/template.md
jonpryor pushed a commit that referenced this issue Jul 18, 2019
…r files (#3362)

Fixes: #3343

Context: https://github.com/xamarin/XamarinComponents/blob/54646f5c0bef9c618c700628bd1167768d7c9b4f/Android/Guava/source/Guava.ListenableFuture/Guava.ListenableFuture.csproj
Context: https://www.nuget.org/packages/Xamarin.Google.Guava.ListenableFuture/1.0.0

We introduced a performance improvement in 5ec3e3a that "classifies"
assemblies as Xamarin.Android assemblies or not.  This allows us to
skip processing of NetStandard/BCL assemblies throughout the build.

Unfortunately, the `Xamarin.Google.Guava.ListenableFuture.dll`
assembly is "odd":

  * No `[assembly: TargetFramework]` attribute at all
  * No reference to `Mono.Android.dll`

Without either of those, 5ec3e3a thinks that this assembly is *not*
a Xamarin.Android-profile assembly, and thus skips processing.

The only "marker" is that `Xamarin.Google.Guava.ListenableFuture.dll`
has is a `.jar` file as an `@(EmbeddedResource)`, which is put there
by the `@(EmbeddedJar)` Build action.

The weirdness is related to it not having any C# code, and it using
SDK-style projects.

Fix support for the `Xamarin.Google.Guava.ListenableFuture.dll`
and similar assemblies by updating the `<FilterAssemblies/>` task to
look for:

  * `[assembly: TargetFramework("MonoAndroid,Version=v9.0")]`
  * `Mono.Android.dll` reference
  * `EmbeddedResource` ending with `*.jar`  (this is new.)
  * `EmbeddedResource` beginning with `__Android`  (this is new.)

I also reworked this task so that the logic is hardcoded. It does not
seem useful to pass in input parameters from MSBuild targets anymore.
jonpryor pushed a commit that referenced this issue Jul 18, 2019
…r files (#3362)

Fixes: #3343

Context: https://github.com/xamarin/XamarinComponents/blob/54646f5c0bef9c618c700628bd1167768d7c9b4f/Android/Guava/source/Guava.ListenableFuture/Guava.ListenableFuture.csproj
Context: https://www.nuget.org/packages/Xamarin.Google.Guava.ListenableFuture/1.0.0

We introduced a performance improvement in 5ec3e3a that "classifies"
assemblies as Xamarin.Android assemblies or not.  This allows us to
skip processing of NetStandard/BCL assemblies throughout the build.

Unfortunately, the `Xamarin.Google.Guava.ListenableFuture.dll`
assembly is "odd":

  * No `[assembly: TargetFramework]` attribute at all
  * No reference to `Mono.Android.dll`

Without either of those, 5ec3e3a thinks that this assembly is *not*
a Xamarin.Android-profile assembly, and thus skips processing.

The only "marker" is that `Xamarin.Google.Guava.ListenableFuture.dll`
has is a `.jar` file as an `@(EmbeddedResource)`, which is put there
by the `@(EmbeddedJar)` Build action.

The weirdness is related to it not having any C# code, and it using
SDK-style projects.

Fix support for the `Xamarin.Google.Guava.ListenableFuture.dll`
and similar assemblies by updating the `<FilterAssemblies/>` task to
look for:

  * `[assembly: TargetFramework("MonoAndroid,Version=v9.0")]`
  * `Mono.Android.dll` reference
  * `EmbeddedResource` ending with `*.jar`  (this is new.)
  * `EmbeddedResource` beginning with `__Android`  (this is new.)

I also reworked this task so that the logic is hardcoded. It does not
seem useful to pass in input parameters from MSBuild targets anymore.
@RobTF
Copy link

RobTF commented Jul 25, 2019

Hi,

This has broken our build; does anyone know what the downgrade steps are for VS2019 on Windows?

@ninaada
Copy link

ninaada commented Jul 25, 2019

Any time line as to when this will be fixed? Our builds have been broken due to this.

@jonathanpeppers
Copy link
Member

jonathanpeppers commented Jul 25, 2019

This was fixed in: #3362

We reopened this issue, so we could get approval to ship this fix in a service release for 16.2.

If you need a workaround, for now you can add this to the bottom of your Android app project's .csproj file:

  <Target Name="FixGuava" AfterTargets="_AddAndroidCustomMetaData">
    <ItemGroup>
      <_MonoAndroidReferencePath Include="@(_ReferencePath);@(_ReferenceDependencyPaths)" Condition=" '%(Filename)' == 'Xamarin.Google.Guava.ListenableFuture' " />
    </ItemGroup>
  </Target>
</Project>

When a public fix is available, we'll close this and mention which version you can update to.

@ninaada
Copy link

ninaada commented Jul 25, 2019

Thanks! This workaround worked for us.

@clintonrocksmith
Copy link

Thank you Jonathan for the work-around.

jonpryor pushed a commit that referenced this issue Jul 31, 2019
…r files (#3362)

Fixes: #3343

Context: https://github.com/xamarin/XamarinComponents/blob/54646f5c0bef9c618c700628bd1167768d7c9b4f/Android/Guava/source/Guava.ListenableFuture/Guava.ListenableFuture.csproj
Context: https://www.nuget.org/packages/Xamarin.Google.Guava.ListenableFuture/1.0.0

We introduced a performance improvement in 5ec3e3a that "classifies"
assemblies as Xamarin.Android assemblies or not.  This allows us to
skip processing of NetStandard/BCL assemblies throughout the build.

Unfortunately, the `Xamarin.Google.Guava.ListenableFuture.dll`
assembly is "odd":

  * No `[assembly: TargetFramework]` attribute at all
  * No reference to `Mono.Android.dll`

Without either of those, 5ec3e3a thinks that this assembly is *not*
a Xamarin.Android-profile assembly, and thus skips processing.

The only "marker" is that `Xamarin.Google.Guava.ListenableFuture.dll`
has is a `.jar` file as an `@(EmbeddedResource)`, which is put there
by the `@(EmbeddedJar)` Build action.

The weirdness is related to it not having any C# code, and it using
SDK-style projects.

Fix support for the `Xamarin.Google.Guava.ListenableFuture.dll`
and similar assemblies by updating the `<FilterAssemblies/>` task to
look for:

  * `[assembly: TargetFramework("MonoAndroid,Version=v9.0")]`
  * `Mono.Android.dll` reference
  * `EmbeddedResource` ending with `*.jar`  (this is new.)
  * `EmbeddedResource` beginning with `__Android`  (this is new.)

I also reworked this task so that the logic is hardcoded. It does not
seem useful to pass in input parameters from MSBuild targets anymore.
@jonathanpeppers
Copy link
Member

This should be out now on the stable channel for VS Windows: https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes#16.2.1

@brendanzagaeski
Copy link
Contributor

Windows fix published. The new Xamarin.Android SDK version 9.4.1.0 that includes a fix for this issue has now been published as part of Visual Studio 2019 version 16.2.1. Check for the latest updates or install the most recent release from https://visualstudio.microsoft.com/downloads/ to get the fix.

macOS fix published. The new Xamarin.Android SDK version 9.4.1.0 that includes a fix for this issue has now been released in the Stable updater channel in Visual Studio for Mac. Check for the latest updates or install the most recent release from https://visualstudio.microsoft.com/downloads/ to get the fix.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
regression vs-sync For internal use only; creates a VSTS "mirror" issue.
Projects
None yet
9 participants