Version Information
Visual Studio Version 17.3.0 Preview 4.0
Xamarin.Android SDK version (13.0.0.0):
AndroidX Libraries as they are in csproj
<PackageReference Include="Xamarin.AndroidX.Annotation" Version="1.3.0.4" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.4.2.1" />
<PackageReference Include="Xamarin.AndroidX.Fragment" Version="1.4.1.2" />
<PackageReference Include="Xamarin.AndroidX.RecyclerView" Version="1.2.1.7" />
<PackageReference Include="Xamarin.AndroidX.SwipeRefreshLayout" Version="1.1.0.9" />
Describe your Issue:
Am trying to start transactions using SupportFragmentManager from AndroidX packages. My Activity is Extending AppCompatActivity also from AndroidX libraries.
Steps to Reproduce
Whenever I try
SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment, title).AddToBackStack("tag").Commit();
it doesnt go through and start getting these issues form the stack trace
Java.Lang.NoSuchMethodError: no non-static method "Landroidx/fragment/app/FragmentTransaction;.replace(ILandroidx/fragment/app/Fragment;Ljava/lang/String;)Landroidx/fragment/app/FragmentTransaction;"
its the same for Replace, Commit, Add, or any other function I try from the SupportFragmentManager. Have noticed that in the AndroidX package libraries all the functions I try and dont go through have the unsafe keyword. I have also enabled my Visual Studio to run unsafe code to see if the calls would go through but still getting same errors. Any help is appreciated. Thanks!
### Exception Stack trace:
{Java.Lang.NoSuchMethodError: no non-static method "Landroidx/fragment/app/FragmentTransaction;.replace(ILandroidx/fragment/app/Fragment;Ljava/lang/String;)Landroidx/fragment/app/FragmentTransaction;"
at Java.Interop.JniEnvironment.InstanceMethods.GetMethodID(JniObjectReference type, String name, String signature) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:line 11481
at Java.Interop.JniType.GetInstanceMethod(String name, String signature) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniType.cs:line 236
at Java.Interop.JniPeerMembers.JniInstanceMethods.GetMethodInfo(String encodedMember) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods.cs:line 90
at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualObjectMethod(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 388
at AndroidX.Fragment.App.FragmentTransaction.Replace(Int32 containerViewId, Fragment fragment, String tag) in C:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release\net6.0-android\generated\src\AndroidX.Fragment.App.FragmentTransaction.cs:line 694
at FingerCheck.Mobile.Android.EmMainActivity.DisplayView(String title) in D:\code\new-ios-mobile-app\mobile-app\FingerCheck.Mobile.Android\UI\Activities\EmMainActivity.cs:line 153
--- End of managed Java.Lang.NoSuchMethodError stack trace ---
java.lang.NoSuchMethodError: no non-static method "Landroidx/fragment/app/FragmentTransaction;.replace(ILandroidx/fragment/app/Fragment;Ljava/lang/String;)Landroidx/fragment/app/FragmentTransaction;"
at crc646632ed322e08ccbe.EmMainActivity.n_onCreate(Native Method)
at crc646632ed322e08ccbe.EmMainActivity.onCreate(EmMainActivity.java:76)
at android.app.Activity.performCreate(Activity.java:8198)
at android.app.Activity.performCreate(Activity.java:8182)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3765)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3968)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8512)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Issue also added here
Related
I saw multiples post/question about it on StackOverflow but about ASP.NET
I am getting the following:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'System.Web.Mvc.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x00099] in /Users/builder/data/lanes/5749/9cfa7836/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:229
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in /Users/builder/data/lanes/5749/9cfa7836/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:179
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver, System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x0015c] in <998d78d5ee6d46b491b77aff8eeaf856>:0
at Xamarin.Android.Tasks.ResolveAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x001c7] in <998d78d5ee6d46b491b77aff8eeaf856>:0 (NightLine.Droid)
Now the interesting point is that my project isn't an ASP.NET project att all x) So first, what the hell?
I did this video: https://channel9.msdn.com/Shows/XamarinShow/Snack-Pack-15-Upgrading-to-XamarinForms-to-NET-Standard
I upgrated the .NET Standard project to 2.0. My Android target is 8.0 and the compiler as well. I tried to upgrade all of my Xamarin.Android.* packages but no success...
Any idea?
Thanks
I'm trying to do a release build of my Xamarin.Android app in Team Services and have got the following error:
The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could
not resolve reference to 'System.Void.Android.Support.CustomTabs.CustomTabsIntent::LaunchUrl(Android.App.
Activity,Android.Net.Uri)' (defined in assembly
'Microsoft.Azure.Mobile.Client, Version=4.0.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35') with scope
'Xamarin.Android.Support.CustomTabs, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null'. When the scope is different from the defining
assembly, it usually means that the type is forwarded. --->
Mono.Cecil.ResolutionException: Failed to resolve System.Void.Android.Support.CustomTabs.CustomTabsIntent::LaunchUrl(Android.App.Activity,Android.Net.Uri)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, 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)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
I can see that it's probably related to the package Microsoft.Azure.Mobile.Client but not sure what I would have to do to resolve it (I'm quite new to Xamarin so not sure what to do with this information).
My minSdkVersion is 21.
Thanks
It looks like the guys of Microsoft.Azure.Mobile.Client package have problems with Android.Support.CustomTabs library. Please refer to the posted issues on github: Issue 364 and Issue 361. It looks like Microsoft.Azure.Mobile.Client version 4.0.0 can be built against Android.Support.CustomTabs version 25.3.1, but Microsoft.Azure.Mobile.Client version 4.0.1 can be built against Android.Support.CustomTabs version 23.3.0.
In my case downgrading nuget package Microsoft.Azure.Mobile.Client from version 4.0.1 to version 4.0.0 helped to build and link my project.
I'm trying to configure MVVMCrosswith Xamarin.Forms. So I'm creating XF project, adding antoher PCL project for viewmodels. Next I'm instaling needed MVVMCross nugets includng Mvvmcross.StarterPack, MVVMCross.Forms and MVVMCross.Presentation. Then I'm cleaning in project from auto created trash ets. To this moment everything building. But when I change in XF MainPage.xaml ContentPage to MvxContentPage in building time there is following error:
The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'StormFinder, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'StormFinder.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() StormFinder.Android
StormFinder is my XF UI project. I've tried everything, including cleaning, reinstalling XF, MVVMCross or even starting new project.
What can I do?
EDIT:
Project can be found there: https://github.com/straiser/StormFinder
EDIT2:
It was wrong namespace in xaml. Project is building now, but now I have got another error:
System.TypeLoadException: Parent class vtable failed to initialize, due to: Type MvvmCross.Forms.Presenter.Core.MvxFormsPagePresenter has invalid vtable method slot 7 with method MvvmCross.Core.Views.MvxViewPresenter:Close (MvvmCross.Core.ViewModels.IMvxViewModel) assembly:/storage/emulated/0/Android/data/StormFinder.Android/files/.__override__/MvvmCross.Forms.Presenter.Core.dll type:MvxFormsPagePresenter member:<none>
06-12 18:52:19.744 E/mono-rt ( 1784): [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Parent class vtable failed to initialize, due to: Type MvvmCross.Forms.Presenter.Core.MvxFormsPagePresenter has invalid vtable method slot 7 with method MvvmCross.Core.Views.MvxViewPresenter:Close (MvvmCross.Core.ViewModels.IMvxViewModel) assembly:/storage/emulated/0/Android/data/StormFinder.Android/files/.__override__/MvvmCross.Forms.Presenter.Core.dll type:MvxFormsPagePresenter member:<none>
You need to include the namespace of the MvxContentPage in your MainPage.
It needs to look like this:
<?xml version="1.0" encoding="utf-8" ?>
<core1:MvxContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:StormFinder"
xmlns:core="clr-namespace:MvvmCross.Forms.Presenter.Core;assembly=MvvmCross.Forms.Presenter.Core"
xmlns:core1="clr-namespace:MvvmCross.Forms.Core;assembly=MvvmCross.Forms"
x:Class="StormFinder.MainPage">
<Label Text="{Binding Text}"
VerticalOptions="Center"
HorizontalOptions="Center" />
<!-- core:MvxContentPage -->
</core1:MvxContentPage>
Severity Code Description Project File Line Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata
item 'System.Void Android.Widget.TextView::SetTextAppearance(System.Int32)' (defined in 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null') from 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.Widget.TextView::SetTextAppearance(System.Int32)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
--- End of inner exception stack trace ---
at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() FeedReader.Droid
I am trying to build My Xamarin.Adroid project for release. But i keep getting this error. General consensus on the web is that that my Targeting framework and minimum SDK versions have to be so and so, but I have tried them all to no avail.
Both those SDK's are installed on my machine, I also have the latest preview of Xamarin forms added.
Nothing I am trying seems to work. Any help regarding this would be greatly appreciated.
Thank you in advance.
Looks like the method Android.Widget.TextView::SetTextAppearance(System.Int32) first appeared in API23: M. You'll need to change your compile and/or target versions to point to M.
After updated xamarin version i start getting thi error. Clean project first then build it again. fixed for me. Rebuild not working.
I have a web app that uses MEF, Webapi and OData.
For MEF I created a helper class that loads the catalog on demand (at first access)
The following is MEF integration code.
Public Shared ReadOnly Property Catalog As AggregateCatalog
Get
If _catalog Is Nothing Then
Dim catFolder = "."
Dim path = AppDomain.CurrentDomain.BaseDirectory.ToLower
_catalog = new AggregateCatalog()
Dim di = New DirectoryInfo(path)
Dim dlls = di.GetFileSystemInfos("MyApp.*.dll")
_catalog = New AggregateCatalog()
For Each dll In dlls
Try
Dim ac = New AssemblyCatalog(Assembly.LoadFile(dll.FullName))
Dim parts = ac.Parts.ToArray() 'throws ReflectionTypeLoadException
_catalog.Catalogs.Add(ac)
Catch ex As ReflectionTypeLoadException
Log.Instance.Error("Error when Trying to load {0}", dll.FullName)
Log.Instance.Error(ex)
For Each iex In ex.LoaderExceptions
Log.Instance.Error(iex)
Next
End Try
Next
End If
Return _catalog
End Get
End Property
One of my projects (the actual web app project) uses the following nuget packages (among others):
WebApi 5.2.3
WebApi.OData 5.7.0
My problem is when MEF class tries to load this assembly (the one that uses OData and WebApi, it thrown a runtime error, which is logged below.
The problem occurs ONLY in deployment, on production machine. In development all works ok.
As you can see in the error below, it seems that, even if the project references System.Web.Http version 5.2.3.0, at runtime System.Web.Http.Odata assembly is trying to load System.Web.Http version 5.2.2.0 (!?!?!?)
In my project, the reference is set to correct dll (version 5.2.3.0), the dll is set with Copy Local=True, and in web.config I have
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
I don't have any class needed to be composed by MEF in this project (assembly), so I could simply exclude it from being load by MEF, but this error is puzzling me, and I would like to find a solution, in case I encounter similar problem in other assemblies.
Here is the error I get
2015-11-04 07:17:02.7758|ERROR|MyPermitNow.Log|Error when Trying to load m:\web\www.mypermitnow.org\web_1\bg-processor\MyPermitNow.Jurisdiction.dll
2015-11-04 07:17:02.7758|ERROR|MyPermitNow.Log|System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetEnumerator()
at System.Linq.EnumerableQuery`1.GetEnumerator()
at System.Linq.EnumerableQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at MyPermitNow.MEFHelper.get_Catalog()
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetEnumerator()
at System.Linq.EnumerableQuery`1.GetEnumerator()
at System.Linq.EnumerableQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at MyPermitNow.MEFHelper.get_Catalog()
2015-11-04 07:17:02.7758|ERROR|MyPermitNow.Log|System.IO.FileLoadException: Could not load file or assembly 'System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
=== Pre-bind state information ===
LOG: DisplayName = System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///M:/web/www.mypermitnow.org/web_1/bg-processor/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Web.Http.OData, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///M:/web/www.mypermitnow.org/web_1/bg-processor/System.Web.Http.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
There could be a lot of things that could cause this. Some things to check:
Is there an old version of the DLL on the server having problems? It is possible the CSPROJ now has Private=true for the assembly when it didn't use to, then that library is included in the main applicate/site project. So the new one isn't getting copied, but the old one is sitting there but in a more direct spot so it is loading first.
Any app/web.config transforms going on that could be replacing the assembly binding XML?
If it's not in the direct application folders, what's in the GAC?
Turn on the Fusion assembly loading logging