I am working on a project where I am trying to have a VS Android project access and deploy an AAR that was created in Android Studio. The Android project in the VS solution is able to reference the classes in the AAR (which is attached as a Binding Library type of project), and the entire solution builds with no errors. However, when I try to deploy the solution to an attached Android tablet I get the following error:
MSB4018: The "GenerateJavaStubs" task failed unexpectedly. System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.v7.AppCompat, Version=188.8.131.52, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile? File name: 'Xamarin.Android.Support.v7.AppCompat.dll' at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference) at Mono.Cecil.MetadataResolver.Resolve(TypeReference type) at Mono.Cecil.ModuleDefinition.Resolve(TypeReference type) at Mono.Cecil.TypeReference.Resolve() at Java.Interop.Tools.Cecil.TypeDefinitionRocks.<GetTypeAndBaseTypes>d__1.MoveNext() at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate) at Java.Interop.Tools.Cecil.TypeDefinitionRocks.IsSubclassOf(TypeDefinition type, String typeName) at Java.Interop.Tools.JavaCallableWrappers.JavaTypeScanner.AddJavaTypes(List`1 javaTypes, TypeDefinition type) at Java.Interop.Tools.JavaCallableWrappers.JavaTypeScanner.GetJavaTypes(IEnumerable`1 assemblies, IAssemblyResolver resolver) at Xamarin.Android.Tasks.GenerateJavaStubs.Run(DirectoryAssemblyResolver res) at Xamarin.Android.Tasks.GenerateJavaStubs.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
In the VS Android project I have NuGet packages for Xamarin.Androidx.* (including AppCompat and Transition) along with Xamarin.Android.Support.v7.AppCompat. I have also tried adding the v7.AppCompat to the binding library project. In addition, when I look at the output window I see several apparently successful references to the v7.AppCompat package prior to the error.
I am using Visual Studio Professional 2019 and deploying to a Samsung Galaxy S3 tablet which has been upgraded to Android 9. My project is set to target Android 9. (I am deploying to a tablet instead of the emulator because the app is using microphone input, which doesn't appear to be available in the emulator.)
Does anyone have any suggestions for how to solve this error?