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

New bunch of warnings using Xamarin.AndroidX.Annotations 1.6.0 #727

Closed
gmck opened this issue May 8, 2023 · 13 comments
Closed

New bunch of warnings using Xamarin.AndroidX.Annotations 1.6.0 #727

gmck opened this issue May 8, 2023 · 13 comments

Comments

@gmck
Copy link

gmck commented May 8, 2023

Android application type

.NET Android (net7.0-android, etc.)

Affected platform version

VS 2022 17.6.0 Prev 6.0

Description

I get a new bunch of warnings since moving to Prev 6 from 5. However, can also observe the same warnings if using 17.5.0. They are all JAVAC warnings

JAVAC : warning : unknown enum constant Scope.LIBRARY_GROUP_PREFIX etc.

Steps to Reproduce

Test project at https://github.com/gmck/NavigationGraph7Net7

Did you find any workaround?

No

Relevant log output

See test project
@jonathanpeppers
Copy link
Member

new bunch of warnings since moving to Prev 6 from 5

There are no Android workload changes between these two builds of Visual Studio.

One error message, I see when I build this project is:

  reason: class file for androidx.annotation.RestrictTo$Scope not found

Are we sure it wasn't the latest AndroidX packages that caused this?

There are 102 Warning(s) like this, but no other information:

JAVAC unknown enum constant Scope.LIBRARY_GROUP_PREFIX
JAVAC unknown enum constant Scope.LIBRARY

@jpobst
Copy link
Contributor

jpobst commented May 8, 2023

It looks like the androidx.annotations.annotations.jar changed dramatically between version 1.5.0 and 1.6.0.

1.5.0

Link: https://maven.google.com/web/index.html#androidx.annotation:annotation:1.5.0

image

1.6.0

Link: https://maven.google.com/web/index.html#androidx.annotation:annotation:1.6.0

image

We will need to investigate where that code went.

@jpobst jpobst changed the title New bunch of warnings using VS 2022 17.6.0 Prev 6.0 New bunch of warnings using Xamarin.AndroidX.Annotations 1.6.0 May 8, 2023
@jpobst
Copy link
Contributor

jpobst commented May 8, 2023

It looks like the code was moved to:
https://maven.google.com/web/index.html#androidx.annotation:annotation-jvm:1.6.0

Unfortunately this appears to use some new system that is not POM files or anything else we have built support for.

The easiest fix would probably be to bind this as a new package and manually add it as a dependency of the Xamarin.AndroidX.Annotation package.

@moljac
Copy link
Member

moljac commented May 16, 2023

Added new bindings for androidx.annotation:aanotations-jvm JAR in #724

https://github.com/xamarin/AndroidX/pull/724/files#diff-45a0a38d395bf4427d0291d9c72bd99b57fa43e14b00e059ae170d657949f1f2R95-R105

@gmck
Copy link
Author

gmck commented May 17, 2023

@moljac
Can you explain how this update works? I don't see any updates when I click on updates in the NuGet package manager.
Were you able to build the supplied test app without all those warnings?

@moljac
Copy link
Member

moljac commented May 20, 2023

@moljac Can you explain how this update works?

No, I cannot explain. Trying to find some clues.

I don't see any updates when I click on updates in the NuGet package manager.

Not published yet.

PR: #724

Were you able to build the supplied test app without all those warnings?

No. I get the same warnings with all samples.

@gmck
Copy link
Author

gmck commented May 23, 2023

@moljac

Thanks for your reply. I didn't realize that it had not been published. I thought that your comment above "Added new bindings" meant that it had been published.

While you are here can you comment on the missing methods OnPrepareMenu, OnMenuClosed in AndroidX.Core.View. per #611, as referenced in #718 Enable DIM for AndroidX packages.

Is this the same thing - Not published yet

@moljac
Copy link
Member

moljac commented May 23, 2023

@moljac

Thanks for your reply. I didn't realize that it had not been published. I thought that your comment above "Added new bindings" meant that it had been published.

In the meantime:

https://www.nuget.org/packages/Xamarin.AndroidX.Annotation.Jvm

Our process is far more complicated now than it was 2-3 years ago (reviews, security and quality checks, you_name_it) and it takes longer just to fight through all steps. Then if I am out of luck I hit stuff like:

CI windows only (mac is greeen all the time):

========================================
ci-setup
========================================

========================================
javadocs
========================================
An error occurred when executing task 'javadocs'.
Error: One or more errors occurred. (The SSL connection could not be established, see inner exception.)
	The SSL connection could not be established, see inner exception.
##[error]PowerShell exited with code '1'.

and have to restart pipelines.

Due to the fact I try to stay sane - I did not look at the problem. Simply restarting helps, but it takes time.

While you are here can you comment on the missing methods OnPrepareMenu, OnMenuClosed in AndroidX.Core.View. per #611, as referenced in #718 Enable DIM for AndroidX packages.

Is this the same thing - Not published yet

No. I don't think so. Or... It could be. Not sure without diving in deeper.

Our tooling is not perfect and even worse - environment changes (tools, languages like java and kotlin), so it could be tons of reasons. In this case java classes (code) was moved to other artifact with -jvm (google does move very often).

@gmck
Copy link
Author

gmck commented May 26, 2023

@moljac, @jpobst

I upgraded the test project to the latest NuGets and I still have a problem with these warnings.

The warnings are still present if you just do a build. However, if you then deploy the warnings disappear other than the two warnings androidx.window.extensions.jar and androidx.window.sidecar.jar which have been there forever.

If you do a clean and then just Deploy, it builds and the deploy succeeds, but you get all the warnings. If you then just deploy again, it deploys in just over 1 sec and the error list clears except for the two androidx.window warnings above.

You should be able to reproduce it with the upgraded sample. The sample also includes a working OnPrepareMenu in the HomeFragment.cs

Now using 17.7.0 P1.0

@moljac
Copy link
Member

moljac commented Jun 8, 2023

@moljac, @jpobst

I upgraded the test project to the latest NuGets and I still have a problem with these warnings.

Can you try Xamarin.AndroidX.Annotation.1.6.0.3 please?

The warnings are still present if you just do a build. However, if you then deploy the warnings disappear other than the two warnings androidx.window.extensions.jar and androidx.window.sidecar.jar which have been there forever.

Previous rounds of published packages were not focused to fix these warnings. Fix was published few days ago.

Fixed in

#738

Now using 17.7.0 P1.0

It is not VS or .NET SDK issue, but AndroidX package[s]. Namely google moves code around and now it is in annotation-jvm artifact.

https://maven.google.com/web/index.html?q=androidx.annotation#androidx.annotation

annotation:1.6.0.pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <!-- This module was also published with a richer model, Gradle metadata,  -->
  <!-- which should be used instead. Do not delete the following line which  -->
  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
  <!-- that they should prefer consuming it instead. -->
  <!-- do_not_remove: published-with-gradle-metadata -->
  <modelVersion>4.0.0</modelVersion>
  <groupId>androidx.annotation</groupId>
  <artifactId>annotation</artifactId>
  <version>1.6.0</version>
  <name>Android Support Library Annotations</name>
  <description>The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs.</description>
  <url>https://developer.android.com/jetpack/androidx/releases/annotation#1.6.0</url>
  <inceptionYear>2013</inceptionYear>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <developers>
    <developer>
      <name>The Android Open Source Project</name>
    </developer>
  </developers>
  <scm>
    <connection>scm:git:https://android.googlesource.com/platform/frameworks/support</connection>
    <url>https://cs.android.com/androidx/platform/frameworks/support</url>
  </scm>
  <dependencies>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib</artifactId>
      <version>1.8.0</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
</project>

annotation-jvm:1.6.0.pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <!-- This module was also published with a richer model, Gradle metadata,  -->
  <!-- which should be used instead. Do not delete the following line which  -->
  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
  <!-- that they should prefer consuming it instead. -->
  <!-- do_not_remove: published-with-gradle-metadata -->
  <modelVersion>4.0.0</modelVersion>
  <groupId>androidx.annotation</groupId>
  <artifactId>annotation-jvm</artifactId>
  <version>1.6.0</version>
  <name>Android Support Library Annotations</name>
  <description>The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs.</description>
  <url>https://developer.android.com/jetpack/androidx/releases/annotation#1.6.0</url>
  <inceptionYear>2013</inceptionYear>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <developers>
    <developer>
      <name>The Android Open Source Project</name>
    </developer>
  </developers>
  <scm>
    <connection>scm:git:https://android.googlesource.com/platform/frameworks/support</connection>
    <url>https://cs.android.com/androidx/platform/frameworks/support</url>
  </scm>
  <dependencies>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib</artifactId>
      <version>1.8.0</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

@gmck
Copy link
Author

gmck commented Jun 9, 2023

@moljac , @jpobst , @jonathanpeppers

Can you try Xamarin.AndroidX.Annotation.1.6.0.3, please?

When I check for updates none are found. Is this to be expected?

If I add 1.6.0.3 manually to the project the warnings do go away.

However, how is one meant to know that this particular NuGet is required? @jonathanpeppers originally picked up on reason: class file for androidx.annotation.RestrictTo$Scope not found which eventually led to the fix.

Could the build system be improved to emit some sort of warning/error indicating that Xamarin.AndroidX.Annotation is required?

@moljac
Copy link
Member

moljac commented Jun 9, 2023

When I check for updates none are found. Is this to be expected?

True. 1.6.0.3 is not listed. Not sure why.

https://www.nuget.org/packages/Xamarin.AndroidX.Annotation.Jvm/1.6.0.3

If I add 1.6.0.3 manually to the project the warnings do go away.

However, how is one meant to know that this particular NuGet is required?

It is not. Only for warnings, because code was moved.

@jonathanpeppers originally picked up on reason: class file for androidx.annotation.RestrictTo$Scope not found which eventually led to the fix.

Could the build system be improved to emit some sort of warning/error indicating that Xamarin.AndroidX.Annotation is required?

Android build system (dependencies) rely on POM files, so we do. This particular POM file did not indicate that annotation-jvm was needed as dependency. Warnings (missing fileds and classes) forced us to check what is going on. The issue was not functional blocker, more aesthetic.

When building AX or GPS-FB-MLKit there are quite a lot "missing class" warnings and I usually ignore them. I dive only if those are culprit that something was not surfaced/bound. Simply resource optimization (my day is 24 hrs too).

@jpobst
Copy link
Contributor

jpobst commented Jul 27, 2023

This should be fixed in Xamarin.AndroidX.Annotation 1.6.0.4.

@jpobst jpobst closed this as completed Jul 27, 2023
JeffBshp added a commit to JeffBshp/BrailleContractionLookup that referenced this issue Oct 26, 2023
Upgrade package: Xamarin.AndroidX.Annotation. Hopefully this is still compatible with the currently installed version of Xamarin.Forms. See this issue:
xamarin/AndroidX#727 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants