-
Notifications
You must be signed in to change notification settings - Fork 533
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
Unable to use import androidx.appcompat.widget.Toolbar into a java file when using AndroidJavaSource #8191
Comments
MacOSX
output:
|
Thanks for the repo app. I have replicated the issue. There is a bug in the In this case the androidx.appcompat has a classes.jar file, but it is inside an .aar file. This .aar file is extracted to the We will need to update our build system to include these files. |
@dellis1972 Thank you. Any timeline for the fix? Will it be fixed in .NET 7? Or is it already fixed in .NET 8? Any workaround at the moment? |
@opcodewriter Its not fixed anywhere at this time. I'll need to figure out what needs to get fixed first. I'll try adn figure out a work around for you |
ok try adding this to your .csproj just above the final
See if that fixes the issue. |
In the actual sample app, there's no more compilation error, but when I try to use it in some actual code, I get this error and many warnings:
|
Try adding https://www.nuget.org/packages/Xamarin.AndroidX.Annotation.Jvm |
same error and warnings. Note my actual code is in a Android .NET 7 library, not an app like in my sample, not sure if it matters. |
….widget.Toolbar into a java file when using AndroidJavaSource Fixes dotnet#8191 TODO
….widget.Toolbar into a java file when using AndroidJavaSource Fixes dotnet#8191 TODO
….widget.Toolbar into a java file when using AndroidJavaSource Fixes dotnet#8191 TODO
….widget.Toolbar into a java file when using AndroidJavaSource Fixes dotnet#8191 TODO
….widget.Toolbar into a java file when using AndroidJavaSource Fixes dotnet#8191 TODO
…8194) Fixes: #8191 The implementation of `@(AndroidJavaSource)` was missing one component: if your project contains `@(PackageReference)`s to NuGet packages which pull in `.jar` files, those `.jar` files would *not* be referenced when building `@(AndroidJavaSource)`. For example, if you reference the [Xamarin.AndroidX.AppCompat][0] package, there is an expectation that `@(AndroidJavaSource)` code should be able to use the type `androidx.appcompat.widget.Toolbar`. Unfortunately, this would fail: Error JAVAC0000 error: package androidx.appcompat.widget does not exist This would fail because the `javac` invocation was missing references to the `classes.jar` files which are extracted into the `$(IntemediateOutputPath)lp` directory. Update the (internal) `$(_CompileBindingJavaDependsOnTargets)` property so that the `_GetLibraryImports` target is a dependency. This will call the chain of targets which extracts the dependent `classes.jar` files and populates the `@(Jars)` ItemGroup which is used in the `_CompileBindingJava` target. This should allow users to write simple wrapper methods in Java that wrap more complex APIs. [0]: https://www.nuget.org/packages/Xamarin.AndroidX.AppCompat/1.1.0.1
Is this going to be released in .NET 8? Thanks. |
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VS 2022 Version 17.6.5
Description
In my Android .NET 7 app, I have a java file where I'm trying to import
Toolbar
fromandroidx.appcompat.widget
:But it gives the following compilation error:
This is the csproj:
I also tried to manually add the following in the csproj but it didn't make any difference:
Note that when using the Toolbar class in C# code, it compiles OK:
Steps to Reproduce
Just create a Android .NET 7 app, add a file called Interop.java like above.
Here's the sample:
AndroidApp5.zip
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: