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

Android Binding didnt work on Maui #9263

Open
matheusouz opened this issue Aug 29, 2024 · 4 comments
Open

Android Binding didnt work on Maui #9263

matheusouz opened this issue Aug 29, 2024 · 4 comments
Assignees
Labels
Area: Bindings Issues in Java Library Binding projects.

Comments

@matheusouz
Copy link

Description

Hey everyone,

I recently ported my Xamarin.Forms app to .NET MAUI, which required updating some private bindings I had created. One of these bindings is for a library that provides extensive information about the phone. However, when I run the app on .NET MAUI, I encounter errors, and it just doesn’t work as expected. I’ve tried updating the dependencies, but without success.

Steps to Reproduce

1.	Open the forms-app project, build the binding project, and run the forms app. The output will be a Base64-encoded text containing some information.
2.	Repeat the process with the maui-app. This will trigger the issue.

Link to public reproduction project repository

https://github.com/matheusouz/dwn-binding-problem

Version with bug

8.0.71 SR7.1

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

is attached in repo
@PureWeen PureWeen transferred this issue from dotnet/maui Aug 29, 2024
@dotnet-policy-service dotnet-policy-service bot added the needs-triage Issues that need to be assigned. label Aug 29, 2024
@jpobst
Copy link
Contributor

jpobst commented Aug 29, 2024

Can you provide the errors you are seeing?

@dotnet dotnet deleted a comment from github-actions bot Aug 29, 2024
@jpobst jpobst added Area: Bindings Issues in Java Library Binding projects. and removed needs-triage Issues that need to be assigned. labels Aug 29, 2024
@jpobst jpobst self-assigned this Aug 29, 2024
@jpobst jpobst added the need-info Issues that need more information from the author. label Aug 30, 2024
@matheusouz
Copy link
Author

matheusouz commented Aug 30, 2024

Hey @jpobst the full log is attached on the repo linked. But we have here too

2024-08-29 18:44:36.750 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.750 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.750 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.750 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.750 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.750 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.750 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.750 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.751 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.751 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.751 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.751 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.751 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.751 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.751 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.751 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.751 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null
2024-08-29 18:44:36.751 18517-18555 f                       com.companyname.mauiapp              E  Exception: addInfo: addAndroidSensor, java.lang.IllegalStateException: @NotNull method kotlin/reflect/jvm/internal/impl/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null

@dotnet-policy-service dotnet-policy-service bot added need-attention A xamarin-android contributor needs to review and removed need-info Issues that need more information from the author. labels Aug 30, 2024
@jpobst
Copy link
Contributor

jpobst commented Aug 30, 2024

Hmm, I haven't seen that error message before, but my guess is that the Java binaries are not making it into your final application.

https://learn.microsoft.com/en-us/dotnet/maui/migration/android-binding-projects?view=net-maui-8.0#embedded-jaraar-files

You might need to add one of these for *.jar files as well:

<DllFiles_net80_Android Include="bin\Release\net8.0-android\*.dll" />
<AarFiles_net80_Android Include="bin\Release\net8.0-android\*.aar" />

Also, you might want to switch to using the NuGet packages we maintain for your dependencies:

https://www.nuget.org/packages/Xamarin.Kotlin.Reflect
https://www.nuget.org/packages/Xamarin.Protobuf.JavaLite

@jpobst jpobst removed the need-attention A xamarin-android contributor needs to review label Aug 30, 2024
@matheusouz
Copy link
Author

I didn’t include the .jar file because the binding doesn’t generate one. Regarding the packages, I tried using the latest versions, but without success.

I’m using these packages to demonstrate the binding working in Forms but not in MAUI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Bindings Issues in Java Library Binding projects.
Projects
None yet
Development

No branches or pull requests

2 participants