-
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
Cannot use Java code generated from C#-written libraries in AndroidJavaSource files #9374
Comments
Your problem here is that the MvxAndroidApplication exists in MvvmCross.dll. So it is not a java type it is a C# type, so the type does not exist in any .jar file which is referenced by the project. One of the limitations mentioned in the docs is that you can only use types which exist in .jar files (
Unfortuately any "java" code that might be generated won't be generated until after the Compile step of the main application has already been run. This is because |
@dellis1972 Yep, that is what I see either. I filed and issue because using MvvmCross in custom .java source was recommended by @jonpryor, so it is expected.to work. So C# classes from C# written libraries are not supposed to be used in AndroidJavaSource files? |
So if you want to If you don't want to bind it, then you probably can as the compilation of non-bindable .java files happens after So if you add
It will compile. You problem will be the java code you just compiled won't be available in C#. |
@dellis1972 Thanks, that is what I thought. May I ask you then help with any workaround for #9334 (if there is any)? Also, should I close issue as not planned? |
Android framework version
net8.0-android
Affected platform version
.NET 8.0.303
Description
Issue inspired by #9334 recommended workaround. I tried to override specific method in Application (precisely, MvxAndroidApplication) class inheritor, which was not possible due to .NET bug, so I asked for workaround. The workaround was to use generated Java class of MvxAndroidApplication, which was impossible due to
package crc6466d8e86b1ec8bfa8 does not exist
error. I tried it with full bin/obj delete + clean + rebuild process, but then found that error happens and Java's MvxAndroidApplication is not even generated, so then tried to first successfully build project without my custom AndroidJavaSource file included, then include and build again. Nothing works.Also tried with CommunityToolit.Maui's
MauiApplication
class, same error, so problem (I suppose) is not in MvvmCross.Looks pretty similar #8191.
Here is sample and build log
Steps to Reproduce
Create new clear project, add MvvmCross library via NuGet, create .java file with this content:
and try to build.
Also you can check sample attached in Description section.
Did you find any workaround?
Nope, but would be grateful for any workaround.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: