Getting build error when trying to upgrade Android 8 to 10 and switching from VS17 to VS 22

DavidR 25 Reputation points
2023-06-07T07:14:51.9533333+00:00

Hello,

I have a Xamarin.Android project developed for Android 8.0 using Visual Studio 2017.

Now I would like to upgrade the Android version from 8 to 11 and open it in VS 2022 at the same a time.

As soon as I do that I get several error messages.

Assembly 'Xamarin.Android.Support.v4' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]', which is no longer supported. Use a newer version of this NuGet package or notify the library author.

Assembly 'Xamarin.Android.Support.v4' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]', which is no longer supported. Use a newer version of this NuGet package or notify the library author.

Assembly 'Xamarin.Android.Support.v4' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]', which is no longer supported. Use a newer version of this NuGet package or notify the library author.

I have already installed the latest version of Xamarin.Android.Support.v4 and still I get this error message. However, only with Visual Studio 22. With 2017 everything is ok.

Der nächste Fehler entsteht sowohl bei VS 17 also auch bei VS 22 sobald ich versuche die Android Version der App von 8 auf 10 oder 11 zu ändern

System.InvalidOperationException: Unable to find the required Android.Runtime.JNIEnvInit 
    method tokens at 
    Xamarin.Android.Tasks.GeneratePackageManagerJava.GetRequiredTokens(String 
        assemblyFilePath, Int32& android_runtime_jnienv_class_token, Int32& 
        jnienv_initialize_method_token, Int32& jnienv_registerjninatives_method_token)
        at Xamarin.Android.Tasks.GeneratePackageManagerJava.AddEnvironment()
        at Xamarin.Android.Tasks.GeneratePackageManagerJava.RunTask()
        at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in             
        /Users/runner/work/1/s/xamarin-android/external/xamarin-android- 
            tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17

I am really at a loss. I really need at least Android 10 to be able to use the Zebra SDK. Otherwise, I would have to write a completely new app with version 10+, which would certainly not please the customer.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,295 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,275 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,656 Reputation points Microsoft Vendor
    2023-06-08T05:53:26.4466667+00:00

    Hello,

    AndroidX replaces the Android Support Library, you should migrate to AndroidX to fix this issue.

    Here is a document about AndroidX migration in Xamarin.Forms, you can refer to it.

    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.


0 additional answers

Sort by: Most helpful