0

I've upgraded my Xamarin Android project from SDK version 12.0 to 13.0. After that I'm getting below error on building the project in Release mode.

The following error occurs 50 times: R8 : Validation error : A type variable is not in scope. Furthermore, the build process fails with the following message: The process '/Library/Frameworks/Mono.framework/Versions/6_12_24/bin/msbuild' exited with code 1.

In the project's Manifest file, the relevant configuration is as follows:

<AndroidDexTool>d8</AndroidDexTool>
<AndroidLinkTool>r8</AndroidLinkTool>
<AndroidLinkMode>Full</AndroidLinkMode>

This issue is coming from R8. If I remove R8, the app builds successfully. However, I am keen on utilizing R8 and would prefer not to proceed without it.

I would greatly appreciate any suggestions or guidance to resolve this issue.

Edit

Below is the Release configuration of my app:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AotAssemblies>true</AotAssemblies>
<EnableLLVM>true</EnableLLVM>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<JavaMaximumHeapSize>2G</JavaMaximumHeapSize>
<AndroidDexTool>d8</AndroidDexTool>
<AndroidPackageFormat>apk</AndroidPackageFormat>
<AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<AndroidLinkMode>Full</AndroidLinkMode>
Saksham Chaudhary
  • 519
  • 1
  • 4
  • 14

2 Answers2

0

I just checked my Xamarin.Android build and they are the same settings that I am using successfully. That would suggest there is something else wrong in your release build section. Could you show all the contents of the release build?

Have you tried it as a net7.0-android build? Those settings are the default in net7, so you don't even have to list them.

user2153142
  • 431
  • 1
  • 4
  • 7
0

I don't understand a couple of your settings because they are non-standard for a release build. You shouldn't be using apk, because Google requires aab. Any particular reason to enableLLV for it is not normally required. At the same time, I would always go with AndroidEnableProfiledAot>true</AndroidEnableProfiledAot to improve startup times. However, I'd suggest having a look at some samples I have on my GitHub. There you will find Xamarin.Android projects that also have a corresponding Net7 version, i.e. Net7 added to the name. That makes it simple to compare the release settings of both versions. You'll notice that the net7 project is far simpler because most of the settings are already defaulting correctly. Take a look at a recent one NavigationGraph7 and NavigationGraph7Net7.

The following documentation while emphasizing net6-net7, also discusses all the old X.A. release settings explaining their use and why they now default the way they do in net7.

https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNet.md

https://github.com/gmck

user2153142
  • 431
  • 1
  • 4
  • 7