0

I have tried to put it above the MainActivity and(i know that) it doesnt fit there; build error:"The GenerateJavaStub task failed", But I dont know how to do it

[Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
[Application(UsesCleartextTraffic = true)]
public class MainActivity : AppCompatActivity

2 Answers2

1

What you actually need is an application class and you can then do this there,

Add a class that inherits from the Android Application class and then do something like below and it should work for you

[Application(UsesCleartextTraffic = true)]
public class MainApplication: Application
{
FreakyAli
  • 13,349
  • 3
  • 23
  • 63
1

In the shared project you should have the AssemblyInfo.cs file. Add the following line at the end of the file:

[assembly: Application(UsesCleartextTraffic = true)] 

Let us know please if it worked for you, thanks.

Reza Rahemtola
  • 1,182
  • 7
  • 16
  • 30