Error XAGJS7009: System.InvalidOperationException: There can be only one type with an [Application] attribute android Xamarin

Viewed 538

After implementing Huawei push service in my android project, I was getting crash on the occurrence of Push Notification, and error was looged

java.lang.UnsatisfiedLinkError: No implementation found for void crc6415d7e49b4cd3bc6f.MyApplication.n_onCreate()

To resolve this error, I crated MyApplication to extend the Application.

[Application]
    public class MyApplication : Application
    {
        public MyApplication(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
        {

        }

        public override void OnCreate()
        {
            base.OnCreate();
        }
    }

then I am getting

Error XAGJS7009: System.InvalidOperationException: There can be only one type with an [Application] attribute; found:,

Note

  1. I have tried adding these lines as well
    #if DEBUG
    [Application(Debuggable=true)]
    #else
    [Application(Debuggable=false)]
    #endif

but still getting the same issue

  1. Already tried Clean and Rebuild solution
1 Answers

You have to delete Application file first. Open The Library project then find XPush-5.0.2.300 -> HmsPush -> Application file then delete it.

Then add below code line to your Application's OnCreate() method if you want to use feature which is relevant to it.

RegisterActivityLifecycleCallbacks(new MyLifecycleHandler());

In addition this problem will be fixed in the next version.

Related