AndroidTypeMapImplementation trimmable removes types that are used in type casts
メンテナーはふだん 1 日以内に返信
@simonrozsival がすでに取り組んでいます。
2026年10月27日 から。
評価
この issue はまだ評価されていません。
説明
Android framework version
Other, net11.0-android (Preview)
Affected platform version
11.0 RC2
Description
When you have <AndroidTypeMapImplementation>trimmable</AndroidTypeMapImplementation> in your csproj and you use a method that retuns Java.Lang.Object and you use a regular type cast. Like in my repro sample I use this.GetSystemService(Context.StorageStatsService) and cast it to StorageStatsManager? then the StorageStatsManager type is trimmed away and the code ends up throwing a InvalidCastException.
var service = (StorageStatsManager?)this.GetSystemService(Context.StorageStatsService);
If I use .JavaCast<StorageStatsManager>() the type is retained and all is good.
var service = this.GetSystemService(Context.StorageStatsService).JavaCast<StorageStatsManager>();
Steps to Reproduce
I have a small repro here: https://github.com/Cheesebaron/JavaLangObjectCastIssueNet11
Run it with dotnet run --project net11cast/net11cast.csproj /p:Configuration=Release
- Create new Android project targeting
net11.0-android - Add
<AndroidTypeMapImplementation>trimmable</AndroidTypeMapImplementation>in your release config - Use a method like
GetSystemService()which returnsJava.Lang.Object - Type cast the
Java.Lang.Objectto something concrete likeStorageStatsManager - Run in release mode
Did you find any workaround?
No response
Relevant log output
10-27 15:38:04.500 1508 1508 D AndroidRuntime: Shutting down VM
10-27 15:38:04.500 1508 1508 E AndroidRuntime: FATAL EXCEPTION: main
10-27 15:38:04.500 1508 1508 E AndroidRuntime: Process: com.companyname.net11cast, PID: 1508
10-27 15:38:04.500 1508 1508 E AndroidRuntime: android.runtime.JavaProxyThrowable: [System.InvalidCastException]: Unable to cast object of type 'Java.Lang.Object' to type 'Android.App.Usage.StorageStatsManager'.
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at System.Runtime.CompilerServices.CastHelpers.<IsInstanceOf_NoCacheLookup>g____PInvoke|4_0(Unknown Source)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at System.Runtime.CompilerServices.CastHelpers.<IsInstanceOf_NoCacheLookup>g____PInvoke|4_0(Unknown Source)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at System.Runtime.CompilerServices.CastHelpers.IsInstanceOf_NoCacheLookup + 0x5(Unknown Source)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at System.Runtime.CompilerServices.CastHelpers.ChkCastAny_NoCacheLookup + 0x0(Unknown Source)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at System.Runtime.CompilerServices.CastHelpers.ChkCast_Helper + 0x16(Unknown Source)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at System.Runtime.CompilerServices.CastHelpers.ChkCastClassSpecial + 0x4b(Unknown Source)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at System.Runtime.CompilerServices.CastHelpers.ChkCastClass + 0xe(Unknown Source)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at net11cast.MainActivity+<GetStorageInformation>d__1.MoveNext + 0x26(Unknown Source)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at net11cast.MainActivity.OnCreate + 0x3f(Unknown Source)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at Android.App.Activity.__n_OnCreate_Landroid_os_Bundle_ + 0x0(Unknown Source)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at Java.Interop.JniMarshal.SafeInvokeAction + 0x10(Unknown Source)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at scrc648536b707fa8b2047.MainActivity.n_OnCreate_Landroid_os_Bundle_(Native Method)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at scrc648536b707fa8b2047.MainActivity.onCreate(r8-map-id-36836d1d3470e82bd783ca3e552fdc39854a9895817d0fb5a9b359a5c4c62e10:1)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7825)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7814)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3246)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3410)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2017)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7397)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
10-27 15:38:04.500 1508 1508 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
10-27 15:38:04.508 1508 1508 I MonoDroid: UNHANDLED EXCEPTION:
10-27 15:38:04.519 1508 1508 I MonoDroid: Android.Runtime.JavaProxyThrowable: Exception_WasThrown, Android.Runtime.JavaProxyThrowable
10-27 15:38:04.519 1508 1508 I MonoDroid:
10-27 15:38:04.519 1508 1508 I MonoDroid: --- End of managed Android.Runtime.JavaProxyThrowable stack trace ---
10-27 15:38:04.519 1508 1508 I MonoDroid: android.runtime.JavaProxyThrowable
10-27 15:38:04.519 1508 1508 I MonoDroid:
10-27 15:38:04.525 3252 4030 W ActivityTaskManager: Force finishing activity com.companyname.net11cast/scrc648536b707fa8b2047.MainActivity
10-27 15:38:04.525 3252 1539 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
10-27 15:38:04.558 3252 4030 D ActivityTrigger: ActivityTrigger activityPauseTrigger
10-27 15:38:04.566 1508 1508 I Process : Sending signal. PID: 1508 SIG: 9
10-27 15:38:04.570 3252 23572 I AdrenoGLES: QUALCOMM build : 99d190e401, I5e6feab613
10-27 15:38:04.570 3252 23572 I AdrenoGLES: Build Date : 12/06/21
10-27 15:38:04.570 3252 23572 I AdrenoGLES: OpenGL ES Shader Compiler Version: EV031.27.05.11_01
10-27 15:38:04.570 3252 23572 I AdrenoGLES: Local Branch :
10-27 15:38:04.570 3252 23572 I AdrenoGLES: Remote Branch : quic/LA.UM.8.11.1.c25
10-27 15:38:04.570 3252 23572 I AdrenoGLES: Remote Branch : NONE
10-27 15:38:04.570 3252 23572 I AdrenoGLES: Reconstruct Branch : NOTHING
10-27 15:38:04.570 3252 23572 I AdrenoGLES: Build Config : S P 8.0.12 AArch64
10-27 15:38:04.576 3252 23572 I AdrenoGLES: PFP: 0x016ee187, ME: 0x00000000
10-27 15:38:04.589 3252 6425 I ActivityManager: Process com.companyname.net11cast (pid 1508) has died: fore TOP
- 主要言語
- C#
- スター
- 2.1k
- フォーク
- 579
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 236
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/android のほかの issue
-
Area: App+Library Build
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Area: Mono.Android
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
dotnet/android#9192 · コメント 4 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
flaky-ci flaky-tests needs-triage
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Area: App+Library Build needs-triage
難易度 4/5 3〜5日 初心者へのやさしさ 56/100
メンテナーはふだん 1 日以内に返信
-
[Flaky test] JavaObjectTest.UnreferencedInstanceIsCollected still fails after finalizer-test fixオープンflaky-tests needs-triage
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug P2
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
:watch: Not Triaged advanced-concepts/subsvc dotnet-csharp/svc
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
[bug] Season images use the season's TMDB id as a TVDB series id対応中かも @ViKodex が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100