Edit

.NET for Android error XA4258

Example message

error XA4258: Java name 'com.example.for' contains invalid or unsupported Java identifier 'for'. Change the package or type name.

Issue

A Java package or type name contains an invalid identifier, a Java keyword, or a restricted type identifier. Java identifier classification follows Java 21's Unicode 15.0 data so it does not vary with the .NET runtime used to build the app.

.NET for Android requires Normalization Form C (NFC) names and rejects combining and format characters because normalizing file systems can change or merge generated Java source paths. Supplementary characters are rejected because Android's class loader cannot resolve classes with supplementary characters in their simple name, even when the exact descriptor is present in DEX.

This can originate from the $(ApplicationId) MSBuild property, the package attribute in AndroidManifest.xml, a managed type name, or an explicit Java name supplied by an attribute such as [Register] or [JniTypeSignature].

Solution

Use an NFC name. Java type segments support Java 21 BMP identifier starts, including currency symbols and connector punctuation, plus decimal digits after the first character. Package segments and Android manifest component type names use the narrower Android-compatible set of BMP letters, decimal digits after the first character, underscores, and dollar signs. Avoid combining, format, and supplementary characters. No segment may be a Java keyword; type names must also avoid restricted identifiers such as record.

For <activity-alias>, these type-name restrictions apply to android:targetActivity, not android:name. The alias name is an arbitrary component identifier and does not refer to a Java class.