dotnet / dotnet/android

Cannot use Java code generated from C#-written libraries in AndroidJavaSource files

Open
#9,374 4 comments 0 reactions 2 assignees Claimed by @jonathanpeppers View on GitHub
Area: App+Library Build
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 20h
Merged PRs (30d)
257

Description

### 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](https://github.com/user-attachments/files/17262939/JcwUsageSample.zip) and [build log](https://github.com/user-attachments/files/17262929/JetBrainsLog.ReSharperBuild_2024_10_04_19_20_42_0130.log)

### Steps to Reproduce

Create new clear project, add MvvmCross library via NuGet, create .java file with this content:
```
package jcwusagesample;
public class BaseApplication extends crc6466d8e86b1ec8bfa8.MvxAndroidApplication {
}
```

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_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.