I've used the dependency injection successfully with other classes but I just created a class that the injection service seems to have a problem with and I don't understand why.
The interface in the main project
namespace MyApp.Infrastructure.AbstractHelpers
{
public interface IDataCacheHelper
{
void ClearData();
}
}
The implementation in the Android project
using MyApp.Droid.Services;
using MyApp.Infrastructure.AbstractHelpers;
[assembly: Xamarin.Forms.Dependency(typeof(IDataCacheHelper))]
namespace MyApp.Droid.Infrastructure.Helpers
{
public class DataCacheHelper : Java.Lang.Object, IDataCacheHelper
{
public DataCacheHelper ()
{}
#region IDataCacheHelper implementation
public void ClearData ()
{
GcmRegistrationService.Unsubscribe ();
}
#endregion
}
}
When I try to call DependencyService.Get<IDataCacheHelper>()
in the main project it says that the default constructor cannot be found.
Any thoughts?