I get the error 'Platform' does not contain a definition for 'Init' in Microsoft.Maui.ApplicationModel.Platform.Init(this, bundle);

Kim Strasser 1,076 Reputation points
2024-11-15T14:57:17.6533333+00:00

I get the following error after updating my NuGet packages: 'Platform' does not contain a definition for 'Init'

Activity1.cs:

using Android;
using Android.App;
using Android.Content.PM;
using Android.OS;
using Android.Views;
using Android.Util;
using Android.Content;
using Microsoft.Xna.Framework;
using SharedCode;
using Plugin.InAppBilling;
using System;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;
using Android.Gms.Common;
using Firebase.Messaging;
using Firebase.Iid;
using Android.Widget;
using Android.Media;
using MediaManager;
using AndroidX.Core.App;
using AndroidX.Core.Content;
using System.Diagnostics;
using Android.Runtime;

protected override void OnCreate(Bundle bundle)  
{      
    AndroidX.Core.SplashScreen.SplashScreen.InstallSplashScreen(this);          
    base.SetTheme(Resource.Style.MainTheme);      
    base.OnCreate(bundle);  
    Microsoft.Maui.ApplicationModel.Platform.Init(this, bundle);

Before updating it worked with the following NuGet packages:

Screenshot 2024-11-15 153337

Now I use the current NuGet packages:

Screenshot 2024-11-15 154043

Is something wrong with my NuGet packages?

In addition, I get these 3 warnings:

Detected package version outside of dependency constraint: Xamarin.AndroidX.Lifecycle.LiveData 2.8.3.1 requires Xamarin.AndroidX.Lifecycle.LiveData.Core.Ktx (>= 2.8.3.1 && < 2.8.4) but version Xamarin.AndroidX.Lifecycle.LiveData.Core.Ktx 2.8.7.1 was resolved.

Detected package version outside of dependency constraint: Xamarin.AndroidX.Lifecycle.LiveData 2.8.3.1 requires Xamarin.AndroidX.Lifecycle.LiveData.Core (>= 2.8.3.1 && < 2.8.4) but version Xamarin.AndroidX.Lifecycle.LiveData.Core 2.8.7.1 was resolved.

Detected package version outside of dependency constraint: Xamarin.AndroidX.Lifecycle.LiveData.Ktx 2.8.3.1 requires Xamarin.AndroidX.Lifecycle.LiveData.Core.Ktx (>= 2.8.3.1 && < 2.8.4) but version Xamarin.AndroidX.Lifecycle.LiveData.Core.Ktx 2.8.7.1 was resolved.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,650 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 76,786 Reputation points Microsoft Vendor
    2024-11-18T08:55:32.3733333+00:00

    Hello,

    get the following error after updating my NuGet packages: 'Platform' does not contain a definition for 'Init'

    Firstly, if .NET version is 8.0, please do not update Microsoft.Maui.Controls , Microsoft.Maui.Controls and Microsoft.Maui.Essentials to the 9.0 or later, please keep the 8.0.100

    <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.100" />
    <PackageReference Include="Microsoft.Maui.Controls.Core" Version="8.0.100" />
     
      <PackageReference Include="Microsoft.Maui.Essentials" Version="8.0.100" />
     
    

    For these 3 warnings, please downgrade your Plugin.InAppBilling version to 7.1.3.

    <PackageReference Include="Plugin.InAppBilling" Version="7.1.3" />
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.