Autofac quit resolving constructors on iOS after Xamarin update - xamarin.ios

So I updated my Xamarin install today to the latest stable version. Since the update, my app won't run on iOS (runs fine on Android)... the error is that it can't resolve the constructor.
Autofac.Core.DependencyResolutionException: No constructors on type 'FutureState.AppCore.Migrations.Migration001' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.
My original constructor is
public Migration001(IUserRepository userRepository,
IRoleRepository roleRepository,
IPermissionRepository permissionRepository,
IPasswordHasher passwordHasher)
{
_userRepository = userRepository;
_roleRepository = roleRepository;
_permissionRepository = permissionRepository;
_passwordHasher = passwordHasher;
MigrationVersion = 1;
}
but I even tried changing it to service location just to see if Autofac would find the constructor.
public Migration001()
{
_userRepository = App.Container.Resolve<IUserRepository>();
_roleRepository = App.Container.Resolve<IRoleRepository>();
_permissionRepository = App.Container.Resolve<IPermissionRepository>();
_passwordHasher = App.Container.Resolve<IPasswordHasher>();
MigrationVersion = 1;
}
but unfortunately, it results in the exact same issue.
Autofac.Core.DependencyResolutionException: No constructors on type 'FutureState.AppCore.Migrations.Migration001' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.
what would cause something like this? This is a Xamarin.Forms app, so the exact same code is run without issue on Android.

Looks like it was an issue with the Xamarian release at that time. I've re-updated to the latest version (yesterday) and no longer have this issue.
Further there were a number of breaking bugs in the September 2014 releases, so if you're on 3.5... upgrade.

I had similar issue after upgrading Xamarin iOS SDK to Alpha (3.9.289). Changing Linker Behaviour to 'Don't link' solved my problem.

Changing Linker Behaviour to Link Framework SDKs Only solved my problem.

Related

Groovy how can I build a custom library and use it in a project as dependency

I have a set of code procedures I use in a lot of places and I'm trying to basically move it to a library.
So I created my library with some unit test and everything was looking promising and at least working localy..
When I went to my project and deleted the files locally and then try to import them from my library as a dependency the code does not work.
I always get this kind of error
Class does not define or inherit an implementation of the resolved method abstract getProperty(Ljava/lang/String;)Ljava/lang/Object; of interface groovy.lang.GroovyObject.
I'm definitely not an expert on groovy but basically I use it in my Jenkins and Gradle for pipelines and some basic packaging or environment deployments.
I can show my class:
class ConsoleRow implements Comparable {
...
final Integer priority
final String rowStatus
final String message
final String rowReportClass
ConsoleRow(Integer priority, String status, String msg, String rowC) {
this.priority = priority
this.rowStatus = status
this.message = msg
this.rowReportClass = rowC
}
#Override
int compareTo(Object o) {
return this.priority <=> ((ConsoleRow) o).priority
}
The line that gives me the error is this actual compareTo when trying to do the "this.priority"
Caused by: java.lang.AbstractMethodError: Receiver class com.abc.insight.jenkins.ConsoleRow does not define or inherit an implementation of the resolved method abstract getProperty(Ljava/lang/String;)Ljava/lang/Object; of interface groovy.lang.GroovyObject.
at com.abc.insight.jenkins.ConsoleRow.compareTo(ConsoleRow.groovy:24)
at com.abc.insight.jenkins.ConsoleOutputHtmlBuilder.processOutput(ConsoleOutputHtmlBuilder.groovy:115)
at com.abc.insight.jenkins.ConsoleOutputHtmlBuilder.processOutput(ConsoleOutputHtmlBuilder.groovy)
at com.abc.insight.jenkins.ConsoleOutputHtmlBuilder.buildReport(ConsoleOutputHtmlBuilder.groovy:20)
at com.abc.insight.jenkins.ConsoleOutputHtmlBuilder$buildReport.call(Unknown Source)
at build_e548mc0tqjmi822clitlsycdk.runReport(C:\dev\repo\insight\insight-health-check\data-foundation\smoke-test\build.gradle:77)
The calling function is just trying to sort a list of those objects
List<ConsoleRow> outputRows = []
...
return outputRows.sort()
The part that gets me really confused is that if instead of importing the library as a dependency I just do this directly in this repo and put my sources in my buildSrc\src\main\groovy\com\abc\insight the code works fine...
So I really think it might be how I package and publish my library that might be wrong.
I'm really sure this is some basic error on my part because I never did a groovy library before but somehow I can't make it work.
It might be that my publication is just wrong, on my library side I'm using this plugins to do the publishing.
plugins {
id 'groovy'
id 'java-library'
id 'base'
}
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
}
I tried to change components.groovy but somehow it does not work.
Any ideas or tips, I think my question probably is showing some really lack of know-how on groovy but looking at the documentation and examples I could not figure it out.
Doing some debug in my IDE the compareTo that generates the exception looks like this.
public int compareTo(Object o) {
CallSite[] var2 = $getCallSiteArray();
return ScriptBytecodeAdapter.compareTo(this.priority, var2[0].callGroovyObjectGetProperty((ConsoleRow)ScriptBytecodeAdapter.castToType(o, ConsoleRow.class)));
}
I tried following this guide and code structure when doing moving the code to a library
https://docs.gradle.org/current/samples/sample_building_groovy_libraries.html
Thanks for any feedback
p.s: My code might look weird, I tried first to have everything with the def blablabla but I was having some issues with typecasting but I don't think this would be the reason for the problem I'm facing.
Anyway I got a look at the generated code in my IDE and I see a lot of get methods just no idea where they expected this getProperty from
Ok this was definitely a user error.
I am using distribution version of gradle 6.5.1
When I did the gradle init to bootstrap my project I was provided with the dependency of gradle groovy-all version 2.5.11
implementation group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.5.11'
I thought that was a mistake and just updated to the latest version.
implementation group: 'org.codehaus.groovy', name: 'groovy-all', version: '3.0.9'
Now the problem is that the project in which I'm using the library is also running with gradle 6.5.1 so probably this version missmatch between compiple and usage was causing the problem.
By reverting to the correct version suggested by gradle the problem is gone.

Regression of IntelliJ IDEA 14 support for Spock Framework?

After upgrading from IDEA 13.1.x to 14.x (14.0.2 at the moment) I see the support for Spock Framework Mock() and Stub() methods got worse.
To be more specific, I mean in-line methods stubbing/mocking with closures like:
MyType stub = Stub {
myMethod() >> { /* do something */ }
}
IDEA 13 is aware of available methods for stubbed type, which is visible on the below screen shot.
size() method is not underlined. It can be navigated to, auto-completed, checked for possible argument types and so on - usual IDE stuff. The same is possible with any other List method inside of the 'stub closure'.
While IDEA 14 lacks this feature which really is a pity. The screen shot below shows it.
size() method is underlined and greyed out. IDE seems to not have a clue what's up.
The same applies to Mock { } method event if invoked with a type as an argument like Mock(MyType) { } (and Stub(MyType) { } respectively)
My question is - is it only me or that's a bug/regression? Or maybe I need to adjust some settings?
EDIT: seems it's a bug / regression. I raised a bug in youtrack. Up vote, please.
There is a bug in storage system, i.e. GDSL works itself, but state is inconsistent across IDE startups.
As a temporary solution:
Project View -> External Libraries -> spock-core
open org.spockframework.idea.spock.gdsl in Editor
wait until Notification about disabled GDSL comes out
use Activate link in the Notification
You should enable GDSL every time you start up your Idea.
This bug is fixed and the fix will be released asap.

coded ui waitforcontrolready not working on VSTT2013 but worked on VSTT2010

I meet the following issues after migration from VSTT2010 to 2013:
all my ....WaitForControlReady(3000); throw exception object reference not defined to object reference
e.g:
UIMap.UIIdentificationWindowWindow.UIIdentificationDocument4.WaitForControlReady(3000);
Is waiting for a popup to be displayed
MonNavigateur.WaitForControlReady();
with:
public static BrowserWindow MonNavigateur; declared in the class
and: MonNavigateur = BrowserWindow.Launch(new Uri(sAppConfigExtranetUri)); in MyTestInitialize() method
I worked like a charm in VSTT2010 ;(
The temporary workaround used is to replace all my WaitForControlReady(); with a not satisfying Playback.Wait(x000);
Anyone has an idea to solve this problem please?
Make sure you upgrade your reference assemblies to the latest version. WaitForControlReady() should be a part of the Microsoft.VisualStudio.TestTools.UITesting assembly. Version 12.0 would be required to run in VS2013.

Xamarin Linker : Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector

With a skeleton project with FirstView from HotTuna package, and with Build linker behavior set to "Link all assemblies", I get the following error:
System.MissingMethodException: Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector
Using NuGet package v3.1.1 for all MvvmCross (4 packages)
LinkerPleaseInclude file does have the line
[MonoTouch.Foundation.Preserve(AllMembers = true)]
Using the latest stable build:
On PC:
Xamarin for VS 1.12.278
Xamarin.iOS 1.12.278
Mac:
Xamarin.iOS 7.2.2.2
Of course with Linker behavior of SDK only, it runs fine. Any suggestions anyone?
Solved; So, with the basic project, there were three consecutive errors in the following order:
System.MissingMethodException: Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector
can be resolved either by --linkskip=Cirrious.Core (ugly), or by including the following in LinkerPleaseInclude.cs
public void Include(MvxPropertyInjector injector){
injector = new MvxPropertyInjector ();
}
Next error is:
Cirrious.CrossCore.Exceptions.MvxException: Failed to construct and initialize ViewModel for type {0} from locator MvxDefaultViewModelLocator - check MvxTrace for more information
This one is difficult; Simple fix is to ofcourse to do a --linkskip=portableLibrary, or to crate an instance of the ViewModel somewhere (perhaps in LinkerPleaseInclude.cs); problem with the second approach at-least in my case is, most of my VM doesn't have a parameter less constructor, and obviously using IOC in this case wouldn't help.
Final Error:
System.ArgumentNullException: missing source event info in MvxWeakEventSubscription
Parameter name: sourceEventInfo
Either use --linkskip=System (ugly), or add the following to LinkerPleaseInclude.cs
public void Include(INotifyPropertyChanged changed)
{
changed.PropertyChanged += (sender, e) => {
var test = e.PropertyName;
};
}
This was enough for my basic project to run with LinkAllAssemblies, Using LLVM optimizer, and Use SGen collector.
Hope this will help anyone looking for a solution.
I hit this when my XCode was out of sync with the latest Xamarin on my Mac. Upgrading XCode to the latest resolved the problem.

Nuget autoupdate in website

For a customer we are trying to build a webb application that they can build patches (new versions) and their customers can by them self by a click in the app update.
I have made some minor experioments on nuget before and had this as an reference:
http://haacked.com/archive/2011/01/15/building-a-self-updating-site-using-nuget.aspx
unfortunatly some of the nuget packages installed and used in this project where to new and not compatible with the nuget package of autoupdate 0.2.1 uses NuGet.Core 1.3.20419.9005.
So i took the autoupdate code and upgraded nuget to 2.5 and fixed all new issues with the new nuget core (changes in functions/parameters etc.).
Now it works so far as i can se wich package is installed, and i can see that there is a new version on the remote server. Howerver when i try to upgrade the local package to the version on the server i get an error:
System.EntryPointNotFoundException: Entry point was not found.
this is where the code goes wrong:
public IEnumerable<string> UpdatePackage(IPackage package)
{
return this.PerformLoggedAction(delegate
{
bool updateDependencies = true;
bool allowPrereleaseVersions = true;
this._projectManager.UpdatePackageReference(package.Id, package.Version, updateDependencies, allowPrereleaseVersions);
});
}
[EntryPointNotFoundException: Entry point was not found.]
NuGet.IProjectSystem.get_ProjectName() +0
NuGet.ProjectManager.UpdatePackageReference(String packageId, Func`1 resolvePackage, Boolean updateDependencies, Boolean allowPrereleaseVersions, Boolean targetVersionSetExplicitly) +1014
NuGet.ProjectManager.UpdatePackageReference(String packageId, SemanticVersion version, Boolean updateDependencies, Boolean allowPrereleaseVersions) +233
the package param is the package i want to upgrade to.
In my web app i got the folder \App_Data\packages that holds my .nupkg file that is installed. On my remote folder i got all installed packages + my new version package.
I dont understand what the entrypoint is and how to solve this issue.
After a lot of time googling and code inspect and re-engineering code, it looks like the problem is in the Microsoft.AspNet.WebPages.Administration wich is only compatible with NuGet.Core (≥ 1.6.2 && < 1.7). Re-engineered the WebProjectSystem class and now it kinda works.
string webRepositoryDirectory = WebProjectManager.GetWebRepositoryDirectory(siteRoot);
IPackageRepository sourceRepository = PackageRepositoryFactory.Default.CreateRepository(remoteSource);
IPackagePathResolver pathResolver = new DefaultPackagePathResolver(webRepositoryDirectory);
IPackageRepository localRepository = PackageRepositoryFactory.Default.CreateRepository(webRepositoryDirectory);
IProjectSystem project = new WebProjectSystem(siteRoot);
this._projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository);
The UpdatePackage methods also dosent seam to do the job, only updates references or something. When uppgrading to a new version of my package (eg. deploy new images or html files) seams like i need to use the following method instead:
public IEnumerable<string> InstallPackage(IPackage package)
{
return this.PerformLoggedAction(delegate
{
bool ignoreDependencies = false;
bool allowPrereleaseVersions = true;
this._projectManager.AddPackageReference(package.Id, package.Version, ignoreDependencies, allowPrereleaseVersions);
});
}
this goes through all my files in the package and seams to replace them.
however i got some weird issues with some files get 0 bytes after upgrade (only binary dll files, what i have seen so far).
Need some more research on this.

Resources