ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
512 stars 106 forks source link

Android release build: Could not resolve reference to 'SQLitePCL.delegate_progress_handler' #384

Closed zoli13 closed 3 years ago

zoli13 commented 3 years ago

We updated in XF project the Android TargetSDK to 29 - which caused lots of "chain reaction", upgrading MvvmCross, Xamarin Forms, AndroidX, etc,etc. Finally, all worked fine, in debug mode.

But in release (AndroidLinkMode=SdkOnly), we have linker error:

Severity    Code    Description Project File    Line    Suppression State
Error       Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'SQLitePCL.delegate_progress_handler' (defined in assembly 'SQLitePCLRaw.provider.sqlcipher, Version=1.1.14.520, Culture=neutral, PublicKeyToken=7bbc99275c710061') with scope 'SQLitePCLRaw.core, Version=1.1.14.520, Culture=neutral, PublicKeyToken=1488e028ca7ab535'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve SQLitePCL.delegate_progress_handler
   at Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
   at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
   at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
   at Mono.Linker.Steps.MarkStep.MarkField(FieldDefinition field)
   at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type)
   at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
   at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
   at Mono.Linker.Steps.MarkStep.Initialize()
   at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
   at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
   at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
   at Mono.Linker.Pipeline.Process(LinkContext context)
   at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   --- End of inner exception stack trace ---
   at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args) in /Users/builder/azdo/_work/451/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Diagnostics/Java.Interop.Tools.Diagnostics/Diagnostic.cs:line 166
   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   at Xamarin.Android.Tasks.LinkAssemblies.RunTask()
   at Xamarin.Android.Tasks.AndroidTask.Execute()   eKreta.Teacher.Mobile.Android   C:\Program Files (x86)\Microsoft Visual Studio 2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets    366 

I tried to add LinkSkip <AndroidLinkSkip>SQLitePCLRaw.provider.sqlcipher;SQLitePCLRaw.provider.sqlcipher.android;SQLitePCLRaw.core</AndroidLinkSkip> Does not help.

These are the nuget packages of the solution.

nuget

What could cause this issue?

ericsink commented 3 years ago

Not sure if this is the problem, but you have a mixture of SQLitePCLRaw 1.x and 2.x packages, which will definitely cause problems of some kind.

zoli13 commented 3 years ago

Thanks. And later I also found your other suggestion:

SQLitePCLRaw 2.x is compatible with sqlite-net-pcl 1.7. SQLitePCLRaw 1.x is compatible with sqlite-net-pcl 1.6.

So I downgraded all, and with this combination, it works fine (highlighted the changes)

nuget