marcojak / MauiMTAdmob

MIT License
109 stars 18 forks source link

App crashes on Android using .NET 8.0 #87

Closed MatanYamin closed 1 week ago

MatanYamin commented 1 month ago

I tried multiple things and the app crashes when using both simulator/real android device.

I want to buy the license but I won't if the plugin doesn't work...

What i did: Installed the plugin (basically even when tried to build now, it crashes)

added .UseMauiMTAdmob() to the MauiProgram

added CrossMauiMTAdmob.Current.Init(this, appId); to MainActivity OnCreate

and the appropiate meta-data to the android manifest.

And it keep crashing when opening the app for Android (Didn't even tried for iOS).

marcojak commented 1 month ago

Hi.

Can you share the log with me?

Right now my guess is that in your Android manifest you haven't added your admob Id.

Could you check that?

If instead the id is there, send me the crash report so I'll be able to identify and fix the issue.

If you don't have the crash report, you could create a public project that has the same issue so I can clone it and find the issue.

MatanYamin commented 1 month ago

I did add the appropriate meta-data (app id) to the Android Manifest before.

Sure, I created a public project and added only the essentials things for the plugin (And didn't change anything else) and it crashes for Android. This is the project, I will be happy to know what's wrong - https://github.com/MatanYamin/TestAdMobPlugin

Note: Change the "APP_ID" with an app id of your own for the test

Just for clarifications, I did the following:

(Using .NET 8.0)

  1. Created new MAUI project
  2. Added .UseMauiMTAdmob() to the MauiProgram
  3. Added CrossMauiMTAdmob.Current.Init(this, appId); to the MainActivity (Android)
  4. Added <meta-data... for the AndroidManifest.xml

And that's it.

MatanYamin commented 1 month ago

@marcojak

Sir, I have a small update.

It works for both Android and iOS when downgraded the version to 1.4.1

I also noticed that I didn't put the '<meta... APPLICATION_ID....' inside the '<application...' tag in android manifest, but it still didn't work on version 1.4.5 after I fixed it,

Only works for 1.4.1 for some reason.

Hope you'll figure it out soon, this is a great plugin.

marcojak commented 1 month ago

Hi @MatanYamin

The project you shared is private or not available. Could you check that it's public and fully accessible? I'll have a look and hopefully, I'll quickly identify and fix the issue with your project or the plugin.

MatanYamin commented 1 month ago

@marcojak

Sorry about that, I made a new one here - https://github.com/MatanYamin/TestAdMobMaui make sure to replace "APP_ID" with your own in the android manifest + MainActivity Init

Again, just for clarifications, I did the following:

(Using .NET 8.0)

Created new MAUI project

  1. Installed your plugin (version 1.4.5)
  2. Added .UseMauiMTAdmob() to -> MauiProgram.cs
  3. Added CrossMauiMTAdmob.Current.Init(this, appId); to -> MainActivity (Android)
  4. Added <meta-data... for the AndroidManifest.xml

And as I said, it works with 1.41 but doesn't work with 1.4.5. Good luck, waiting for updates!

marcojak commented 1 month ago

Perfect thanks. I'll update you asap.

marcojak commented 1 month ago

I've downloaded the code added a few tweaks to make it work on my Mac M3 and it didn't crash. The code was almost empty, the only thing you added was the init and it simply worked.

Do you have a crash log I can have a look at?

Also, have you tried the sample code? Does it work?

In the sample code, in the csproj I also add the following packages:

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-ios'">
    <PackageReference Include="Xamarin.Google.iOS.MobileAds" Version="8.13.0.3" />
    <PackageReference Include="MT.Xamarin.Google.iOS.UserMessagingPlatform" Version="1.1.0.4" />
</ItemGroup>

Try to add this to your csproj or even better, try to download the sample code....it's the best way to start with the plugin as it has all the methods and events.

MatanYamin commented 1 month ago

The project was intended to be empty to demonstrate that it crashes when fresh.

Anyway, the mistake might have been on my side, as the 1.4.5 version works for me after some modifications.

I'll definitely be purchasing the unlimited apps license.

Thanks for your help—much appreciated!

marcojak commented 1 week ago

Closing as not related to the plugin.