dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.94k stars 533 forks source link

Manifest Errors #8180

Closed MikeP0911 closed 1 year ago

MikeP0911 commented 1 year ago

Android application type

.NET Android (net7.0-android, etc.)

Affected platform version

VS 2022 Version 17.6.4

Description

The Working Android Xamarin project is not working recently. Not sure about the reason.

Error:

Severity Code Description Project File Line Suppression State Error C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\obj\A1_0_LicenseDebug\90\lp\11\jl\AndroidManifest.xml Warning: Namespace 'android.support.graphics.drawable' used in: AndroidManifest.xml, AndroidManifest.xml.

android:exported needs to be explicitly specified for element <service#crc64f1f4a51cb1a8d14b.NotificationService>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

Directory 'obj\A1_0_LicenseDebug\90\lp\11' is from 'Xamarin.Android.Support.Animated.Vector.Drawable.dll'. ZipExtractor.Android C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\obj\A1_0_LicenseDebug\90\AndroidManifest.xml 48

Xamarin.Forms - 4.4.0.991757 Microsoft.Intune.MAM.Xamarin.Android - 3.0.4635.1 Xamarin.Essentials - 1.4.0 Xamarin.Firebasemessaging -71.1740.4 .NET standard framework - 2.0

Android.Manifetst.XML

<?xml version="1.0" encoding="utf-8"?>

Steps to Reproduce

  1. Build the project
  2. with all these settings it throws an error as mentioned above.

Did you find any workaround?

No response

Relevant log output

Build started...
1>------ Build started: Project: SharpCompress, Configuration: Debug Any CPU ------
Restored C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\SharpCompress\SharpCompress.csproj (in 16 ms).
Restored C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor\ZipExtractor.csproj (in 50 ms).
NU1605: Detected package downgrade: Xamarin.Forms from 4.4.0.991864 to 4.4.0.991757. Reference the package directly from the project to select a different version. 
 ZipExtractor.Android -> ZipExtractor -> Xamarin.Forms (>= 4.4.0.991864) 
 ZipExtractor.Android -> Xamarin.Forms (>= 4.4.0.991757)
Restored C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\ZipExtractor.Android.csproj (in 72 ms).
1>C:\NugetPackages\system.text.encoding.codepages\7.0.0\buildTransitive\net461\System.Text.Encoding.CodePages.targets(4,5): warning : System.Text.Encoding.CodePages 7.0.0 doesn't support net461 and has not been tested with it. Consider upgrading your TargetFramework to net462 or later. You may also set <SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings> in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk.
1>SharpCompress -> C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\SharpCompress\bin\Debug\netstandard2.0\SharpCompress.dll
1>SharpCompress -> C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\SharpCompress\bin\Debug\netstandard2.1\SharpCompress.dll
1>SharpCompress -> C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\SharpCompress\bin\Debug\net461\SharpCompress.dll
1>SharpCompress -> C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\SharpCompress\bin\Debug\net6.0\SharpCompress.dll
1>SharpCompress -> C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\SharpCompress\bin\Debug\netcoreapp3.1\SharpCompress.dll
1>Done building project "SharpCompress.csproj".
2>------ Build started: Project: ZipExtractor, Configuration: A1_0_LicenseDebug Any CPU ------
2>C:\NugetPackages\xamarin.forms\4.4.0.991864\build\Xamarin.Forms.targets(189,5): warning : Xamarin.Forms recommends TargetPlatformMinVersion >= 10.0.14393.0 (current project is -1)
2>C:\NugetPackages\xamarin.forms\4.4.0.991864\build\Xamarin.Forms.targets(195,5): warning : Xamarin.Forms recommends TargetPlatformVersion >= 10.0.17763.0 (current project is -1)
2>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor\Views\Viewer.xaml.cs(130,30,130,32): warning CS0168: The variable 'ex' is declared but never used
2>ZipExtractor -> C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor\bin\A1_0_LicenseDebug\netstandard2.0\ZipExtractor.dll
2>Done building project "ZipExtractor.csproj".
3>------ Build started: Project: ZipExtractor.Android, Configuration: A1_0_LicenseDebug Any CPU ------
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(267,5): warning XA0113: Google Play requires that new applications and updates must use a TargetFrameworkVersion of v11.0 (API level 30) or above. You are currently targeting v9.0 (API level 28).
3>C:\NugetPackages\xamarin.googleplayservices.basement\71.1620.4\build\MonoAndroid90\Xamarin.GooglePlayServices.Basement.targets(59,3): warning : Failed to find client_info in google-services.json matching package name: jp.co.cegb.archxtractpush
3>C:\NugetPackages\system.text.encoding.codepages\7.0.0\buildTransitive\net461\System.Text.Encoding.CodePages.targets(4,5): warning : System.Text.Encoding.CodePages 7.0.0 doesn't support net461 and has not been tested with it. Consider upgrading your TargetFramework to net462 or later. You may also set <SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings> in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk.
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CSharp" that could not be resolved.
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277: There was a conflict between "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:     "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:     References which depend on "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Microsoft.CSharp.dll].
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:         C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Microsoft.CSharp.dll
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:           Project file item includes which caused reference "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Microsoft.CSharp.dll".
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:             Microsoft.CSharp
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:     References which depend on "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:         C:\NugetPackages\csvhelper\30.0.1\lib\netstandard2.1\CsvHelper.dll
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:           Project file item includes which caused reference "C:\NugetPackages\csvhelper\30.0.1\lib\netstandard2.1\CsvHelper.dll".
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:             C:\NugetPackages\csvhelper\30.0.1\lib\netstandard2.1\CsvHelper.dll
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:             C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor\bin\A1_0_LicenseDebug\netstandard2.0\ZipExtractor.dll
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:         C:\NugetPackages\microsoft.identity.client\4.54.1\lib\monoandroid90\Microsoft.Identity.Client.dll
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:           Project file item includes which caused reference "C:\NugetPackages\microsoft.identity.client\4.54.1\lib\monoandroid90\Microsoft.Identity.Client.dll".
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:             C:\NugetPackages\microsoft.identity.client\4.54.1\lib\monoandroid90\Microsoft.Identity.Client.dll
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3277:             C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor\bin\A1_0_LicenseDebug\netstandard2.0\ZipExtractor.dll
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\ZipService.cs(108,62,108,75): warning CS0618: 'Forms.Context' is obsolete: 'Context is obsolete as of version 2.5. Please use a local context instead.'
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\ZipService.cs(108,77,108,90): warning CS0618: 'Forms.Context' is obsolete: 'Context is obsolete as of version 2.5. Please use a local context instead.'
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\ZipService.cs(116,13,116,26): warning CS0618: 'Forms.Context' is obsolete: 'Context is obsolete as of version 2.5. Please use a local context instead.'
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\ZipService.cs(354,52,354,65): warning CS0618: 'Forms.Context' is obsolete: 'Context is obsolete as of version 2.5. Please use a local context instead.'
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\ZipService.cs(368,62,368,75): warning CS0618: 'Forms.Context' is obsolete: 'Context is obsolete as of version 2.5. Please use a local context instead.'
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\ZipService.cs(368,77,368,90): warning CS0618: 'Forms.Context' is obsolete: 'Context is obsolete as of version 2.5. Please use a local context instead.'
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\ZipService.cs(406,59,406,72): warning CS0618: 'Forms.Context' is obsolete: 'Context is obsolete as of version 2.5. Please use a local context instead.'
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\ZipService.cs(419,66,419,79): warning CS0618: 'Forms.Context' is obsolete: 'Context is obsolete as of version 2.5. Please use a local context instead.'
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\ZipService.cs(419,81,419,94): warning CS0618: 'Forms.Context' is obsolete: 'Context is obsolete as of version 2.5. Please use a local context instead.'
3>  ZipExtractor.Android -> C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\bin\A1_0_LicenseDebug\ZipExtractor.Android.dll
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(402,5): warning XA0125: 'ZipExtractor.pdb' is using a deprecated debug information level.
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(402,5): warning XA0125: Set the debugging information to Portable in the Visual Studio project property pages or edit the project file in a text editor and set the 'DebugType' MSBuild property to 'portable' to use the newer, cross-platform debug information level.
3>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(402,5): warning XA0125: If this file comes from a NuGet package, update to a newer version of the NuGet package or notify the library author.
3>C : \Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\obj\A1_0_LicenseDebug\90\lp\11\jl\AndroidManifest.xml warning : 
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\obj\A1_0_LicenseDebug\90\AndroidManifest.xml(48,5): java.exe error AMM0000: C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\obj\A1_0_LicenseDebug\90\lp\11\jl\AndroidManifest.xml Warning:
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\obj\A1_0_LicenseDebug\90\AndroidManifest.xml(48,5): java.exe error AMM0000:   Namespace 'android.support.graphics.drawable' used in: AndroidManifest.xml, AndroidManifest.xml.
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\obj\A1_0_LicenseDebug\90\AndroidManifest.xml(48,5): java.exe error AMM0000: 
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\obj\A1_0_LicenseDebug\90\AndroidManifest.xml(48,5): java.exe error AMM0000:   android:exported needs to be explicitly specified for element <service#crc64f1f4a51cb1a8d14b.NotificationService>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
3>C:\Users\saranya.anbalagan\Downloads\test\Mobile\ZipExtractor\ZipExtractor\ZipExtractor.Android\obj\A1_0_LicenseDebug\90\AndroidManifest.xml(48,5): java.exe error AMM0000: Directory 'obj\A1_0_LicenseDebug\90\lp\11' is from 'Xamarin.Android.Support.Animated.Vector.Drawable.dll'.
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 3:00 PM and took 34.418 seconds ==========
dellis1972 commented 1 year ago

It is a requirement now that all services need to define the android:exported attribute on them. This error is being raised for the service element included in the AndroidManifest from the Xamarin.Android.Support.Animated.Vector.Drawable Nuget Package.

The android:exported requirement is only required for android 12 (API 31) and above. What I suspect happened is you recently updated and now your targetSdkVersion is 31 (or above). I can see from the manifest you posted it is indeed 33 . So a couple of options.

  1. Stop using the Android Support packages and move to AndroidX. The Android Support packages have been deprecated by google for a while now. They are unlikely to get any updates. The error will be caused by the AndroidManifest.xml file included in the support package which does NOT have the required attributes.
  2. Reduce your targetSdkVersion to 30. That might make the error go away, but it might also stop you publishing on the play store... not sure what the minimum reqirements are these days.
  3. Make use to the Manifest Merger tooling to inject the required element. See https://github.com/xamarin/xamarin-android/blob/a850d8147d6c1d066f3849e7cf8fab231497c64b/Documentation/guides/building-apps/build-items.md?plain=1#L142. The AndroidManifestOverlay ItemGroup can help with that.

See https://developer.android.com/build/manage-manifests for details on how to use the manifest merger.

MikeP0911 commented 1 year ago

@dellis1972 Thank you for you reply.

We are currently using Target Android SDK version is Android 11.0 - Api level 30 Minimum Android Version is 9.0 - Api Level 28 Target Android Version is 13.0 - Api level 33

  1. AndroidX migration required API level 28 or higher.
  2. Our app uses Intune. So The current Xamarin bindings for Android platform only support apps targeting Android 9.0 and lower and Xamarin Forms 4.4 and lower.

Since our app is built using Xamarin.Forms and uses Intune, Not sure what to be done to balance all the constraints.

Looking forward to your support.

dellis1972 commented 1 year ago

If you can't move your target sdk's or upgrade to AndroidX then I suggest reading up on the manifest merger tooling which I linked in the previous comment https://github.com/xamarin/xamarin-android/issues/8180#issuecomment-1630538029. This should allow you to inject the required android:exported attribute into the final AndroidManifest.xml file which should allow the build to succeed.