Xam.Forms.VideoPlayer
Xam.Forms.VideoPlayer copied to clipboard
System.InvalidOperationException: Application cannot have both a type with an [Application] attribute and an [assembly:Application] attribute.
I've developed an application and I've and [assembly:Application] inside the AssemblyInfo.cs source file.
[assembly: Application(Label = "biker.click")]
When I compile the Android version of the project, the following error is showed:
System.InvalidOperationException: Application cannot have both a type with an [Application] attribute and an [assembly:Application] attribute.
I think the problem is caused by the [Application] attribute inside the source file Xam.Forms.VideoPlayer.Android/MainActivity.cs at line 15
namespace Xam.Forms.VideoPlayer.Android
{
{
[Application]
public partial class MainActivity : Application, Application.IActivityLifecycleCallbacks
Dear @pro777s, can you remove it?
Thank you
Hello, @aperrone, In order to remove this attribute, i will have to abandon the implementation of the interface IActivityLifecycleCallbacks.
Please do - because it breaks all our projects that depend on this ability.
Cant use this plugin due to this
I found out that Xamarin Essentials now offers a MediaPlayer when you enable the extended functionality. There is no need for another library @chrisfoulds
@logikonline sorry I have been on xamarin essentials GitHub and can't see this, do you have a link ?
@chrisfoulds https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/mediaelement
thank you @logikonline , ah forms experimental instead of essentials, either way perfect thank you sir
Here is what the user chedabob wrote to me on this issue:
I ran into this issue because in my Android AssemblyInfo.cs, I had an #ifdef block to turn debugging on and off.
Solution was to remove that block, and create an Application class where I could set that attribute.
My Application class ended up looking like this
#if DEBUG [Application (Debuggable = true)] #else [Application (Debuggable = false)] #endif public class MyApplication: Android.App.Application { public MyApplication(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { } }
Try it until you've tested it.
That didn't work me for in the end. I've had to remove any reference to Application from my code, but will need to find a solution for setting Debuggable but it works for now.
I solved this problem by adding the attribute debuggable to the AndroidManifest.xml: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.anyapp" android:debuggable="false" .../>