marcojak / MauiMTAdmob

MIT License
104 stars 17 forks source link

Version 1.1.0 crashes apps #58

Closed erossini closed 5 months ago

erossini commented 5 months ago

I saw you released the version 1.1.0 of your component. So, I updated it but there are some issues with the dependencies:

MSB4024 The imported project file "C:\Users\enric.nuget\packages\xamarin.google.ios.usermessagingplatform\1.1.0.1\buildTransitive\Xamarin.Google.iOS.UserMessagingPlatform.targets" could not be loaded. The '_GoogleUserMessagingPlatformAssemblyName' start tag on line 3 position 6 does not match the end tag of '_GoogleMobileAdsAssemblyName'. Line 3, position 132. LanguageInUse C:\Projects\ERDevOps\LIUApp\LanguageInUse\obj\LanguageInUse.csproj.nuget.g.targets 115

"C:\Users\enric.nuget\packages\xamarin.google.ios.usermessagingplatform\1.1.0.1\buildTransitive\Xamarin.Google.iOS.UserMessagingPlatform.targets" was not imported by "C:\Projects\ERDevOps\LIUApp\LanguageInUse\obj\LanguageInUse.csproj.nuget.g.targets" at (115,5), due to the file being invalid. LanguageInUse C:\Users\enric.nuget\packages\xamarin.google.ios.usermessagingplatform\1.1.0.1\buildTransitive\Xamarin.Google.iOS.UserMessagingPlatform.targets 115

JAVA0000 Error in C:\Users\enric.nuget\packages\xamarin.androidx.collection.jvm\1.3.0.2\buildTransitive\net7.0-android33.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class: Type androidx.collection.ArrayMapKt is defined multiple times: C:\Users\enric.nuget\packages\xamarin.androidx.collection.jvm\1.3.0.2\buildTransitive\net7.0-android33.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class, C:\Users\enric.nuget\packages\xamarin.androidx.collection.ktx\1.2.0.9\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.class Compilation failed java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\enric.nuget\packages\xamarin.androidx.collection.jvm\1.3.0.2\buildTransitive\net7.0-android33.0....\jar\androidx.collection.collection-jvm.jar androidx/collection/ArrayMapKt.class at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:126) at com.android.tools.r8.D8.main(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:5) Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\enric.nuget\packages\xamarin.androidx.collection.jvm\1.3.0.2\buildTransitive\net7.0-android33.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class at Version.fakeStackEntry(Version_8.1.56.java:0) at com.android.tools.r8.M.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:5) at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:81) at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:32) at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:31) at com.android.tools.r8.utils.R0.b(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:2) at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:26) at com.android.tools.r8.D8.b(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:13) at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:24) at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:113) ... 1 more Caused by: com.android.tools.r8.utils.b: Type androidx.collection.ArrayMapKt is defined multiple times: C:\Users\enric.nuget\packages\xamarin.androidx.collection.jvm\1.3.0.2\buildTransitive\net7.0-android33.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class, C:\Users\enric.nuget\packages\xamarin.androidx.collection.ktx\1.2.0.9\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.class at com.android.tools.r8.utils.O2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:21) at com.android.tools.r8.utils.O2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:26) at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:44) at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:10) at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056) at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:6) at com.android.tools.r8.graph.b4$a.e(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:7) at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:58) at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:9) at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:8) at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:29) at com.android.tools.r8.D8.d(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:17) at com.android.tools.r8.D8.c(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:1) at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:28) ... 6 more LanguageInUse 1

I reverted to 1.0.4 and the app is working as usual.

marcojak commented 5 months ago

Hi, This is actually an issue UMP package.

After downloading it (you now already have it on your PC), go in your nuget cache directory, find the UMP package, find the file Xamarin.Google.iOS.UserMessagingPlatform.targets and find the line with <_GoogleUserMessagingPlatformAssemblyName>Google.UserMessagingPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

and replace it with:

<_GoogleUserMessagingPlatformAssemblyName>Google.UserMessagingPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

Do it and it will work again. I'll see if I can do something to fix this or duplicate the package (not sure if I can legally do it...)

Any questions let me know.

marcojak commented 5 months ago

I've just updated the plugin to version 1.1.1.

This will add a new dependency replacing the damaged one.

It should work now.

erossini commented 5 months ago

Thank you! I have just tried the new version. On Android (i haven't checked iOS), I get an error on the page where the banner is supposed to be displayed.

System.Exception: 'MTAdmob not initialised. You need to initilise it by calling CrossMauiMTAdmob.Current.Init in your platform projects!'

image

marcojak commented 5 months ago

Hi Enrico,

The error is quite clear. In your android project you need to call CrossMauiMTAdmob.Current.Init(...)

This is because of the mandatory consent required by Google. Instead of calling mobileads.init, call this new one and the library will take care of the rest.

Please, remember that from the 16th of January, you need to ask consent to the EU users...the licences version of the plugin can do it, otherwise you need to add your implementation of a certified CMP.

I hope it helps, otherwise let me know and I'll be happy to help.

Marco

On Sat, 27 Jan 2024, 18:15 Enrico Rossini, @.***> wrote:

Thank you! I have just tried the new version. On Android, I get an error in the page where the banner is supposed to be displayed.

System.Exception: 'MTAdmob not initialised. You need to initilise it by calling CrossMauiMTAdmob.Current.Init in your platform projects!'

image.png (view on web) https://github.com/marcojak/MauiMTAdmob/assets/9497415/9d5a974b-cbe7-4a85-9c9c-b1ec65556c7a

โ€” Reply to this email directly, view it on GitHub https://github.com/marcojak/MauiMTAdmob/issues/58#issuecomment-1913264123, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUIPIVVGTAZD6USPUOXI6DYQUYZPAVCNFSM6AAAAABCL6FUPOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJTGI3DIMJSGM . You are receiving this because you commented.Message ID: @.***>

erossini commented 5 months ago

I have

MobileAds.Initialize(this);

So, I have to change it, right?

marcojak commented 5 months ago

Correct.

The library will then call it for you. If you have the licensed version, it will ask for consent and then, if given, will call it. The unlicensed version will just call it, but you need to ask for the consent implementing it, possibly before calling the init method.

On Sat, 27 Jan 2024, 18:22 Enrico Rossini, @.***> wrote:

I have

MobileAds.Initialize(this);

So, I have to change it, right?

โ€” Reply to this email directly, view it on GitHub https://github.com/marcojak/MauiMTAdmob/issues/58#issuecomment-1913266003, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUIPIVQKHUSRNSOFX3EKZTYQUZWDAVCNFSM6AAAAABCL6FUPOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJTGI3DMMBQGM . You are receiving this because you commented.Message ID: @.***>

erossini commented 5 months ago

When do you think the Rewarding will be fixed for iOS? ๐Ÿ˜

erossini commented 5 months ago

Is this correct for Android?

CrossMauiMTAdmob.Current.Init(this, Constants.ApplicationId, Constants.MauiMTAdmobLicence);

and yes, I got a licence ๐Ÿ˜Š

What is the call for iOS?

erossini commented 5 months ago

In my code I have a generic function

        public void InitAdv(bool setEvents = true)
        {
            _shouldSetEvents = setEvents;

#if ANDROID || IOS
            CrossMauiMTAdmob.Current.TagForChildDirectedTreatment = MTTagForChildDirectedTreatment.TagForChildDirectedTreatmentTrue;
            CrossMauiMTAdmob.Current.TagForUnderAgeOfConsent = MTTagForUnderAgeOfConsent.TagForUnderAgeOfConsentTrue;
            CrossMauiMTAdmob.Current.MaxAdContentRating = MTMaxAdContentRating.MaxAdContentRatingPg;
#endif
        }

with the new update, the banner is not displayed but the rewording yes.

marcojak commented 5 months ago

That's perfect.

There are additional parameters in case you want to do some tests. They allow you to test the case for European and non European users.

Instead, if you are ready for release time, the parameters you used are perfect.

Remember to do the same for iOS if your app runs on that platform too.

On Sat, 27 Jan 2024, 18:49 Enrico Rossini, @.***> wrote:

Is this correct?

CrossMauiMTAdmob.Current.Init(this, Constants.ApplicationId, Constants.MauiMTAdmobLicence);

and yes, I got a licence ๐Ÿ˜Š

โ€” Reply to this email directly, view it on GitHub https://github.com/marcojak/MauiMTAdmob/issues/58#issuecomment-1913273830, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUIPIQDFU6KZKCV5Q6HLSTYQU44BAVCNFSM6AAAAABCL6FUPOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJTGI3TGOBTGA . You are receiving this because you commented.Message ID: @.***>

marcojak commented 5 months ago

From version 1.1.0, because you cannot show ads until you have the consent, you need to manually load the banner.

YourAdview.LoadAds() will allow you to load the banner.

On Sat, 27 Jan 2024, 19:17 Marco Troncone, @.***> wrote:

That's perfect.

There are additional parameters in case you want to do some tests. They allow you to test the case for European and non European users.

Instead, if you are ready for release time, the parameters you used are perfect.

Remember to do the same for iOS if your app runs on that platform too.

On Sat, 27 Jan 2024, 18:49 Enrico Rossini, @.***> wrote:

Is this correct?

CrossMauiMTAdmob.Current.Init(this, Constants.ApplicationId, Constants.MauiMTAdmobLicence);

and yes, I got a licence ๐Ÿ˜Š

โ€” Reply to this email directly, view it on GitHub https://github.com/marcojak/MauiMTAdmob/issues/58#issuecomment-1913273830, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUIPIQDFU6KZKCV5Q6HLSTYQU44BAVCNFSM6AAAAABCL6FUPOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJTGI3TGOBTGA . You are receiving this because you commented.Message ID: @.***>

marcojak commented 5 months ago

Closing as fixed in 1.1.1