Error when building in Release mode

Hi,

I updated my monogame to 3.4, then changed to platform target to 4.0+, and downloaded some platform version in sdk manager.

Now when I’m building in release mode, I keep getting this kind of error. I’m not sure what I did but it was all working fine in monogame 3.2.

Error	19	The "LinkAssemblies" task failed unexpectedly.
    Mono.Cecil.ResolutionException: Failed to resolve OpenTK.Graphics.ES20.PixelInternalFormat
       at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
       at Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference)
       at Mono.Linker.Steps.MarkStep.InitializeFields(TypeDefinition type)
       at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
       at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
       at Mono.Linker.Steps.MarkStep.Initialize()
       at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
       at Mono.Linker.Pipeline.Process(LinkContext context)
       at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
       at Xamarin.Android.Tasks.LinkAssemblies.Execute()
       at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
       at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__1.MoveNext()

Any response or help would be appreciated.

EDIT:
working fine when building in Debug mode
Everythings working with 3.2.
Same error in 3.3

Anyone?

My android seems stuck at 3.2 at the moment :frowning:

Have you tried changing the linker behavior to not link anything in Release? Of course this will increase the size of your application, but I think it’s a good diagnostic step.

1 Like

That’s awesome, able to build in release mode now.

Though it followed with different error when packaging before deploying, still trying to look.

System.Exception: The “BuildApk” task failed unexpectedly.
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Ionic.Zip.ZipFile._InternalAddEntry(ZipEntry ze)
at Ionic.Zip.ZipFile.AddFile(String fileName, String directoryPathInArchive)
at Xamarin.Android.Tasks.BuildApk.AddNativeLibrary(ZipFile apk, String path, String abi)
at Xamarin.Android.Tasks.BuildApk.AddNativeLibraries(ZipFile apk)
at Xamarin.Android.Tasks.BuildApk.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__1.MoveNext()

It seems to be related to https://github.com/mono/Monogame/issues/2981

Will try this…

Ok deleting duplicate *.so files seems to work and able to build and create package.

Now when I deploy the huge package to my phone, it doesn’t run or probably crashes.

I’m getting this error when using the emulator…

09-29 11:30:00.729 W/monodroid-gc( 890): GREF GC Threshold: 1800
Loaded assembly: …dll
Loaded assembly: …dll
Loaded assembly: Lidgren.Network.dll
Loaded assembly: MonoGame.Framework.dll
Loaded assembly: …dll
Loaded assembly: Mono.Android.dll [External]
Loaded assembly: System.Core.dll [External]
Loaded assembly: MonoDroidConstructors [External]
Loaded assembly: System.dll [External]
Loaded assembly: OpenTK-1.0.dll [External]
09-29 11:30:03.019 W/ ( 890): Missing method OpenTK.Platform.Android.AndroidGameView::set_RenderOnUIThread(bool) in assembly OpenTK-1.0.dll, referenced in assembly MonoGame.Framework.dll
An unhandled exception occured.

Android is so frustrating.

My question is, can I build and deploy an app using Monogame 3.4 using Xamarin.Android 4.8?

Is there an official requirement for Monogame 3.4 that I missed?

I haven’t had any issues recently. The last I built in release on Android was about a month ago. I’ll try again when I get home tonight.

Thanks.

Are you using Xamarin 4.8? Is there a minimum platform target required for 3.4?

I wanted to use 3.4 because of the fast app resume fixes but if it can be implemented in 3.2 I would be more happy since our game is close to release.

Android fast app resume by danzel · Pull Request #2753 · MonoGame/MonoGame · GitHub danzel mentioned…

Edit: If the build fails on the build bot, it may need its Xamarin.Android updating to at least 4.12.3.

Android Context Lost Fix by dellis1972 · Pull Request #2769 · MonoGame/MonoGame · GitHub dellis1972 say…

Note because of the new api these changes will NOT be compatible with older versions of Xamarin.Android.

Can anyone confirm if 3.3 or 3.4 needs at least Xamarin.Android 4.12?