Monogame With Xamarin or Maui (IOS /Android)

i got essentials to work, its only a bit more bloated… just by adding the one line as was suggested to my existing android…sample with shared core code… mine mg samle works. with simple shader.

but i get the same error wiht the MautMtAdmob nuget.
dont have time now but googling it might show the answer…

however the MG stuff worked before i hooked to that.
System.IO.FileNotFoundException: Could not load assembly ‘Microsoft.Maui, Version=, Culture=neutral, PublicKeyToken=’. Perhaps it doesn’t exist in the Mono for Android profile?
File name: ‘Microsoft.Maui.dll’

rSeverity Code Description Project File Line Suppression State
Error XALNS7028 System.IO.FileNotFoundException: Could not load assembly ‘Microsoft.Maui, Version=, Culture=neutral, PublicKeyToken=’. Perhaps it doesn’t exist in the Mono for Android profile?
File name: ‘Microsoft.Maui.dll’
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:line 245
at Mono.Cecil.MetadataResolver.Resolve(TypeReference type) in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/MetadataResolver.cs:line 111
at Mono.Cecil.TypeReference.Resolve() in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/TypeReference.cs:line 278
at Java.Interop.Tools.Cecil.TypeDefinitionCache.Resolve(TypeReference typeReference) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionCache.cs:line 20
at Java.Interop.Tools.Cecil.TypeDefinitionRocks.d__5.MoveNext() in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionRocks.cs:line 40
at Java.Interop.Tools.Cecil.TypeDefinitionRocks.IsSubclassOf(TypeDefinition type, String typeName, IMetadataResolver resolver) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionRocks.cs:line 94
at MonoDroid.Tuner.FixAbstractMethodsStep.FixAbstractMethods(AssemblyDefinition assembly)
at Xamarin.Android.Tasks.LinkAssembliesNoShrink.RunTask()
at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17 AndroidApp C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.4\tools\Xamarin.Android.Common.targets 1426

trimming, AOT, is off… the bare sample is 40 mg vs 30 mg for the plain xamarin -MG… so theres some bloat added… I cant get trim or code shrink or emulation to work though… i m trying x64 versoin of emulators… now i target ARM64 but i read its faster using x64 emulators… so i updated NDK… havent got one workingn tho… updated sdks . I can deploy release and debug on Samsugn phone one year old… ive updated ndk, and sdks and stufff… targeting newest droind but minimum suppport for 23… so i might try the ad host thing you mention… I havent deploy on play yet thoough, not sure it it will sideload ad stuff.

Regardless a touch laptop makes it much easier to develop for android as you can make a touch app for windows and work with that first… then when that works do the rest on a real device w usb …

thanks for the quick replies how did you get around these error messages?

for you it’s a sdk stack problem how can I. work around this problem? i am using mac x64 visual studio mac 17.5 thanks again

i was hoping you would know lol…

googlin g the error on Maui told me that @TheKelsam actually found it . MSFT bot closed the issue as limited but w workaround, but theres some changes you must make in your project files.

. whats its said thast disturbs me is essentials isnt enouguh and i got to add the useMaui in entirety. Which likely means more bloat.
this is why mabye he said he went for another solution… Theres a bit of manual work involved and it doesnt look easy …

i will probably try the steps sometimes this next 30 days i donno… I have zillion other things to do.

i dont see why android sdk is hosting the Interstitial ads for ios there might beranother way via ios store. Usually a competitor pays YOU to pop up ads for their game which is similar to your game. if your game is better you win. they watch the ad or go to the toilet, come back play your game more. If they dont click it your still get paid more than banners. i just wan to put pop up ad when the user runs out of lives or something… and doesnt want to pay. So anyone is welcome to experiment in that… or ad banners samples i don’t care.

you are wellcome to branch my

and test on osx and or ios…

no reason we should each have to do common stuff like this, but since MONOGAME is just a rendernig framework we should have the communty build little common things over it…

and add admob stuff to it. My project

its set on net 7 whch is released i think or wlll be before anywone acutally deploy anything… on mg3.8.1

also welcome to test consoleGL on mac or if theres a better way to unify the desktop parts … I am all ears. But in your case you mght not need that since you dont have a touch screen but you can stll develop your core game … on your dev machine.

dont put any keys or store stuff in my vault tho. I have never deployed on app store im sideloadng now and halfway through the Beta steps to get mne beta hosted on play.

I only care about Interstitial full page ads… These are video ads that show full screen. I amd not not going to pollute my game wiht banners or tricky ad buttons or in-game stores.

On the MG game host, structure, its based on the firsst netcore sample from MG thats support both desktip and mobile

I dont know if if this is still best way to organise code but a shared folder option is essentially lnked to every exe and the “Bait and Switch”., ( link Monogame GL to the core) and each EXE is linked to the appropriate target, and builds the content, seems to work on MG 3.8.1 and the Compute fork which uses ShaderConductor and its quite different on shaders and has no IOS… The current branch i think is net7 wtith out of box mg 3.8.1 via nuget.

Regadless you dont need any flashy shaders , the sample is more of a realworld- X platfrom game.

havent decided which way to go Compute or MG and doubt they get merged because even my simple shader break on the new one . yo can comment out #define RENDERTARGETTEST and just add your ad stuff to the iospart… render a simple sprite as a test or add a button.

So for a game of any complexity breaking apart the Data, physics , AI, Graphics, and Draw stuff , and UI, into shared DLLs… is paramount to organising code and having fast builds. Factoring out core stuff, and all that , ts the only way… The only template doesnt work i dont have time to PR it and i wouldnt expect it to get merged soon anways.

I used tohave to add an asset in multiple places and have repeat code to deploy to different platfroms… Or use the Sharded itemsm follder,

now i have everything but GameConsoles all in this one Sln . Nicely organized a bit like Nez. and the first MG net core sample. However some of the code hacks on shaders no longer needed since MG 3.8.1 and /or the compute branch fixed the stuff i was working around. its really really hard to get a singe fx shader as simple as clipping to work on N platforms… But its nice to just touch the fx and see changes in all targets…

Trmming has not been successful yet nor have i actaully deployed singed AAb to the play beta yet and this is hard. I think its safe to ignore anythng thats not 32 bit. nowadays.

MG 3.8.1 EXE, doest not allow to link to net standard 2.0 so giong back to the old admob mght be an issue. I dont know how @TheKelsam mabye found a way around this…

deployment on adroind requres separate aabbs… lots of testing and work…and maintainence. that will be by focus… if i decide to use admob the code can mabye be shared…

i ve never provisoned an IOS device or own one, nor have a license yet, and wont tilll late next year if ever… if they had touch screens i would have got a macbook… To me the best way is to develop the touch ap on desktop, then get all your common UI in place, then finish it up on the devices. I’ll reach out to some other devs mabye they will collab on this…

i gotta work on another aspect but i did update everything i had to do with xamarin , add a few more virtual devices, and add mabye ADD ANYCPU back … so i can emulate on X64 hardware witouth makng a fake arm device.

my preferred setup would be a surface running ARM or runnnig google apps on my intel based surface… So i can use the touch screen and 2nd prefernence is debug via usb. Emulation is dog slow so far.

Here is the other thread ill ask if they are still using this kind of stuff. or have any mobile experience. Shader that works in XNA 4.0 is broken in MonoGame - #41 by Damian_Eaglestein

1 Like

thanks for the great information I really like the idea :bulb: :grinning: of ​​developing something in common for the community it saves everyone a lot of time and it will be more stable over time a ghithub around it? do you want us to launch this? It will save a lot of energy and a lot of time. personally I have been working for a while on the subject for discouraging results I’m ready to go

thank you all for your help you are great
I have already succeeded thanks to your recommendation to complete the project with the Maui dependencies
but when I add the admob plugin it’s where everything goes wrong
the last error I had was this after a long fight
.../AndroidMonoGame/BINDINGSGENERATOR: Error BG0000: System.IO.IOException: The process cannot access the file '.../AndroidMonoGame/obj/Debug/net6.0-android/ generated/src/Com.Google.Android.Ump.ConsentDebugSettings.cs' because it is being used by another process. (BG0000) (Android MonoGame)

this could be just a leak… I would pull up Task maanger close anything running that looks like game or hosting, then all your devstudios,emulators, etc… reboot … its the Kelslam that wnet through this hell and decided on another approach… thats why i think we should collabe on basics like this… .i ll send you the pitch… and try to recruit people with experience… MOst successfu games follow multiple failure and MG is jsut too low level… its can take YEARS to do ship a game but tis the best choice for indies IMO…ones that have original ideas and want to cast a wide net on a billion devices to find their fan base…

1 Like

hell yes… i want to show samples of shaders how to build a very basic game loop, loading N cores…using shared dlls… . and all the mobile and desktop projects that to deploy on IOS, Android and destops for Steam… dont care for UWP, but mabye wrapp the windows EXE with that windows store thing noone really uses…
Mabye put the WPF -MG update i have working thats unmerged, or someone can try build an Avalonia level editor basic sample wiht MG in it… and make a shader playground… I dont want to go as far as Nez and make an ECS… or full game engine, i want ot just focus on the lastest Net 7, SIMD, game loop basics, stable framerate , and common shaders that work on the most devices , and ad hosting. aslo to try out the compute branch its seems unlikely to get merged but its very promising since Epic games is maintaing part of shader conductor … its more alive and have more features and tranpiling but evne my old clip shader is now broken…

ill try to refine this comment and pitch it around … i need to ship a game that almost succeeded so i cant do all the work…

To succed at an indie game we shoul be focued on game mechanincs , art, charactesr and mood design, our fans, original ideas, not be limited to rehashing sutff from Unity Asset stores, but to realizing our dreams, making unique games and casting a wide net to find fans… if our game will likely fail and the first attempt 90% will, best not to spend 5 yeasr to find out noone else cares about ur vision. Engage with the few fans you find, and mabye you can get 100x more from the encouragement and direction they give you in fanmail. To leverage all the stuff MSFT opened up, and the unified monogame graphics API… Theres no other game in town buyt MG is just way too hard… and we all have pretty much the same hurdles.

It should not taek 2 years to port a game to MG. and it does. show some ways to serialize levels. it can have many SLNs and sampls but i wouold like the common stuff to stay merged… I want to explore the compute shader but take some of the pressure off the core devs, by showing techiques and samples in thin layers and core games just over MG. Aslo we can share the struggles areound basic ad hosting and the getting a Minimal viable product and demo… something to reach a 1 billion devices… as indies we need to focus on art and sound and charactesr, game mechanices, and share the burden of these common techincal issues that all have the same workaroudn or trick…

Shader transpiling and rendering on one thread on a Huge array of paltfroms, for that Monogame is the only option. and we can releive pressure off the core team and share the burden of this common stuff by having a good sampls vault and playground… with some clean core samples, and some experiements as well. I hope to prevent too mnay branches of MG . ill see if i can refine this pitch and if someone in the comunity will help contribue… ill put in what im willing to share… Because i hope to save people time and compete on the merits of how good my art is and how fun my game is, not just that i fgured out the tricks to deploy basic stuff… make MVPs or demos to raise funding and such shouldnt take years…

1 Like

I fully agree with your reasoning.
the time we spend on our own to solve a problem we can optimize it and devote more time to developing and improving the game
I think it is important to develop things in common to solve things like advertising
and that this should no longer be a problem for the MG community
How much will it cost to go faster?
like that we ask for a harvest
I think a lot of people would be more interested I think it would encourage more people to join the community

Hello everyone I hope you are doing well?
Are there people who want to embark on this adventure?
to create a plugin for advertisements?
reliable and regularly updated
if we unite our efforts we will do better and faster
Can someone run the plugin skeleton?
Do you have any other ideas?
Are there people who are interested in this kind of plugin?

if yes send yes


1 Like

Thanks , But i reach the error already on android , get the same error just by changing from essentials to full Maui, add some nuget stuff arround consent, and afraid i can’t get further any time soon. i just changed to maui from essentials on my android launcher and its shows… Now i have to install all this stuff… and have zillion new things to learn.

then, i see this… many a whole new way…

do you have a git that is public w a sample? just the ad for IOS? you had a “long fight” mabye someone can pick up from the progress.

so google this… after you shave down the error code to simplify it.

re: AndroidMonoGame/BINDINGSGENERATOR: Error BG0000: System.IO.IOException: The process cannot access the file ‘…/AndroidMonoGame/obj/Debug/net6.0-android/ generated/src/Com.Google.Android.Ump.ConsentDebugSettings.cs’
this is the User Messaging Platfrom of android…
i get to

so i guess yo might need install this sdk if you didnt.

…also for me more study is needed at an executive level and ethics legalities and stuff…

im sure sure i even want to go this path yet tho…

im on Net 7 and vs 2022. (stll curious about HOw)
if i have to revert to xamarin there might be ways, to use net6 , and MG, and ads, but the old Consent SDK is deprecated.

i can be reasonable or practical sometimes but im supposed to be designing horrific monsters .and making a demo . and now ive tried full maui i dont know if A. It can work wiht MONOGAME 3.8.1 Net6 at all. and hosting adds vai admob . Does you ios sample host a simple MG window? is it on Github? i might be having less troube since im doign androind and the Ios goes through the google stack. appartently…

B. if my separate IOS / windows/ Android should be one project.
C. Beside HOW, i should use interstiatial ads , i need to know WHY, and all the ethics, concent and legalities around it or if i can put by own “show Ad opt in” button, to get game credits and “opt in” Plus outside of the EU its different rules…
D. what if i do it the old way… or not use interstial but another sort of ad with Xamarin andMG.3.8.1 and Net7

so im not ready to host and refine the scope of Common X gameCore samples, and supposed to be on a surf vacation before sesason ends, might be gone for a month.

Either way to get further I think you need to be in Beta and have an account on admob.

have an App ID, and im not there. im sideloading and need to refine my demo first this is all too much … you -can -run test adds tho.

the ad host is just for android and ios… it can be on any vault sample, that dosnt care about desktop or linux. . but i dont know how to install hte consent sdK , mabye after i beef up my xamarin and androind stuff… you are using Ios u might have more trouble than me, but i thinkn its all going through Google anywasy…

for ads, its all about mobile… ios and droid… my shared code/ shader thing isnt that relevant…

as for the sample with core core… its not getting much attention.

I’ll issue a call for action later, on the best way to share code target Xplatfrom, im too lost in doubt and confusion right now. I need focus on my core tech and see how this pans out…im not ready for deployment on mobile and legalities and permissions… probably focus on steam

first, i need to release somehwere soon, and mobile seems too hard a place to start. sorry i cant help more, just don’t know and too much is changing… thx for sharing your stuggle tho… its woken me to Maui…maybe i will use it later…

1 Like

i updated the net7 branch on my sample i mentioned… I did get it to build and i put some notes. I got further but to get futher I i have to put Java interop code I googled up to get the official permission thing required by the EU. And all the safety for kids and stuff… I feel bad for themgrowing up on phones… I have to sign to Admob, do all ths legal agreements, and Google Play has alot of scamming apps. Like Williams Pinball that pops up all these buttons, AND you have no idea how to dismiss and how not to spend like 100$ . So im leaving it and the internet for i while im burned out and need to go outside. Things change every week now. Im making a game that encourages kids to learn physics and play outside lol, but its killing me. Burned out for now… might hopefully take a break, its rainign but im going outside , get on a real motorcycle and go night surfing or talk to actaul humans or something. I hate games, lol, thats why i feel i have to make a different kind based on physics. Sorry cant get all the way through it but i think the rest is in Java interop, even in the case of iOS, since its goign from CS, to java i beleive… if admob is a google API… When i pressed Maui targets then, my whole thing asked me if i tanet to target IOS, Android, and Windows and then everything broke so I just left it with the one like “useMaui” and didnt touch the UI… it builds, deploys as ABB, not APK, then it runs and fails at runtime to get persmissions from the “victims” … ok sorry thats all i have and its in the net7 branch in my vault. You can see my diffs notes and comments if they help but i need a break/ or go back to my wave simulation which i enjoy,i hate boiler plate code and thats all im doing here… for months.

1 Like

Thank you very much for your help, am I the only one having this problem?
how did you get the permissions?

You are right rest well and enjoy
thank you

I left off because there needed to be code in java or CS , thats asks permissions, via a formal protocol. Because targeted ad hosting is essentially, or at least potentially, a lot of controversial spyware . Tutorial for using Xamarin.Google.UserMessagingPlatform (GDPR) for Google AdMob

Some of the technical coding and methodology apply only for the EU countries…
and the USA is the biggest market. All the hopes might not be necessary in every demographic you wish to be visible on … but this is current as of Feb 2022…

I don’t collect special data, ask almost zero , permissions , and have simple privacy policy i submitted to Google. But , a phone can do alot of harm and as a ton of sensors. Im not ready because I care first about the reviews, so i plan to deploy without ads for a upfront low price or free sample or something. before I explore all this stuff.

I do like that people wiith zero money can play a game and devs still get compensated, but i need to know how to protect my fans, and theres alot of options to consider. You don’t know what they will see while they play your game and how it will reflect on you.

Google just send me a message with lots to read. You need an Admob account set up.
@TheKelsam said these apis and laws change all the time. And its changing again in preview. So i’m going in a “holding pattern” and not planning to host ads for a while. The tricky thing is that you are doing IOS and Xamarin is going via Google.
There are other options to explore as well. The advice I put might be outdated already.
Google Ads AdMob SDK - Profile,Market Share,Similar SDKs

and finally Apple is starting to resort to ads and mighth have an sdk you can access via swith or whatever interop…I suggest just get thte basic adbmob thing going and jump through the hoops… if you don’t target EU, mabye its easier, but there is lots to explore.

1 Like

thank you for all those informations
just a note the marcojack example
works for me
why would it be different with maui on monogame ?
GitHub - marcojak/MTAdmob: Admob plugin for Xamarin Android and iOS
je pense qu’on se rapproche de la solution :thinking:

so it works without Maui? mabye its my setup., my x platfrom sln i never got feedback from the experts… They said mobile shouldnt work with a core game DLL but for me it does SEEM to. at least for android… . BTW i see new samples Neonshooter, wtih alll platfroms, 3.8.1… shaders and such… Mine for Mobile some are using the core dll… which cannot be a netstandard dll, the eXe must be linked directly to a net 6 +dll. anywayss i link admob dirfectly to my EXE… i didnt expect to share code on this… not sure… if you ur emulatator is asking permissions then its working i guess…

some (mobile) use linked files… Admob xamarin, might use netstandard. anyways the samples, works better than my setup…I have to weight this… maybe this, like to avoid Maui if possible.

Also theres an old admob sample in MG… not been updated… but the branches with updated sampes are marked .net6… also i suggest going to net7… If you have some issues… They are fixing stuff every day around xamarin… i would watch those samples for updates… I havent had a watch on activity them, there are getting attention. From core maintainers…

re: other desktop platfroms and one codebase: ( other topic of xplatfrom)
also confusing is the desttip GL is marked but it s should depploy on linux … lots to learn… I dont mark a tartet use a console GL… then it puts all the linux packages and such…was suggget to try but that doesnt necessary mean windows on Windows… still some stuff needs to be ironed out…

1 Like

i hope you are fine ?
I did not succeed
but what I wanted to say is that the example of GitHub - marcojak/MTAdmob: Admob plugin for Xamarin Android and iOS works on maui we manage to see the banners, interstitials, …
why it shouldn’t work with MG
That’s the question I ask myself
does anyone have an idea?

to your issue there was an admob sample in MG samples. that used to work… it might help you. aslo The Kelsam explained it well at top… i suspect its something to do with Netstandard… being dropped in net 6 if you have to revert to MG. 3.8.0 and can ship it … mg. 3.8.1 inst that much better… it has teh POTENTIAL to be much better and you might look at the branches 3.8.1 on samples. like i said there an old Admob samle in MG it does this…
there sare 5 samples udpates to the MG 3.8.1 branch of samples. I dont konw if you cna use legacy sdk tho. but mabye find a way combining keslam advice, review what he said above.

also try dev studio preview and Net 7. they aer updating this every week… 1000+ people on all ths stuff… and well managed…apparently… somehow its going well , at least older tech moving foward… Xamarin isnt going away. the MG samples from @SimonDarksideJ are good… they are fast . the emulator now works for me. i dont konw why they have to link all the FX yet tho… thast hard to maintain…

does this help? from the old sample…
[Activity (Label = “MonoGame.Samples.AdMob”, MainLauncher = true
, Icon = “@drawable/icon”, Theme = “@style/Theme.Splash”,ConfigurationChanges=ConfigChanges.Orientation|ConfigChanges.Keyboard|ConfigChanges.KeyboardHidden)]
public class Activity1 : AndroidGameActivity
View adView;
protected override void OnCreate (Bundle bundle)
base.OnCreate (bundle);
Game1.Activity = this;
var g = new Game1();
FrameLayout fl = new FrameLayout(this);
adView = AdMobHelper.CreateAdView(this,“publisherid”);
SetContentView (fl);


thansk for asking, im not OK…tooo much being online on on computers and not being in realitiy… surfing in a rogue tropical nation where i can afford to spend time on this stuff…) …

Mabye ill start a mental health discord for Indie game devs. spend all night on some WPF bug thats dont by a junior indonesian dev. is 10 year old code… his code 3x more complex than needed. i want to scrap it and rewrite… I cant hire anyone and a recruiteer sends me another email sayign WPF job, medical devices for 200k… iignore and sob, ill never find anotheor competent staff i dont have to train or can afford.

1 Like

and BTW the admob Maui doesnt support interstitial it says… i might give it a try tho if i stop sobbing my heart out… Best thing yoy or SOMEONE coudl do… fork the MG ADMOB sample from Monogame sampes… put a Watch all active on there…

try and get it working with ur code and 3.8.0 and latest sdk on xamarin.

add a mg. 3.8.1 branch… thry to update it … thants what peole have been doing in the samples valut… if i pull 3.8.1 brach i see 5 nice samples there from core MG gusy with tons of experience… theres Neone shooter… running on adroind and desktop with shaders…

1 Like

thank you you are right there is confusion between the targets What’s frustrating is that I feel like there’s not a lot missing for this to work. I’m wondering, is it only me who has this problem?