This class definition causes an immediate runtime crash on Xamarin for Android.
public class BaseCompatActivity : Android.Support.V7.App.AppCompatActivity
{
protected override void OnResume()
{
base.OnResume();
}
}
The error message is:
Java.Lang.UnsatisfiedLinkError: Native method not found: md5e8727ee9d36911e204981187fd2b13a2.BaseCompatActivity.n_onResume:()V
I have an inheritance chain that goes like this
MainActivity > DrawerActivity > BaseCompatActivity > AppCompatActivity
If I override OnResume in MainActivity or DrawerActivity, there is no problem. It is only if I override it in BaseCompatActivity that I get that error message.
This happens when running API level 17 in the emulator. It does not happen when running on an API level 22 device.
What could be causing this mysterious behaviour?
Related
After implementing Huawei push service in my android project, I was getting crash on the occurrence of Push Notification, and error was looged
java.lang.UnsatisfiedLinkError: No implementation found for void crc6415d7e49b4cd3bc6f.MyApplication.n_onCreate()
To resolve this error, I crated MyApplication to extend the Application.
[Application]
public class MyApplication : Application
{
public MyApplication(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
}
public override void OnCreate()
{
base.OnCreate();
}
}
then I am getting
Error XAGJS7009: System.InvalidOperationException: There can be only one type with an [Application] attribute; found:,
Note
I have tried adding these lines as well
#if DEBUG
[Application(Debuggable=true)]
#else
[Application(Debuggable=false)]
#endif
but still getting the same issue
Already tried Clean and Rebuild solution
You have to delete Application file first. Open The Library project then find XPush-5.0.2.300 -> HmsPush -> Application file then delete it.
Then add below code line to your Application's OnCreate() method if you want to use feature which is relevant to it.
RegisterActivityLifecycleCallbacks(new MyLifecycleHandler());
In addition this problem will be fixed in the next version.
I'm trying to achieve RightToLeft direction in my project. Other things working fine but label isn't moving to right in iOS for that purpose I have created a LabelRenderer in which I'm passing this method MakeTextWritingDirectionRightToLeft(null) but I'm getting exception
Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UILabel makeTextWritingDirectionRightToLeft:]: unrecognized selector sent to instance 0x7fd2fb68b680
Can anyone tell me what to pass in the parameter of this function instead of null?
You can try to use following code to achieve RightToLeft direction in my project.
[assembly: ExportRenderer(typeof(Label), typeof(CustomLabel))]
public class CustomLabel: LabelRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
base.OnElementChanged(e);
Control.TextAlignment = UITextAlignment.Right;
}
}
I have an iOS application written in Xamarin and I am getting a Unity Exceptions Resolution Failed exception when I try and run the application in iOS. However this error does not happen when I run the android version of the application. The exception is being thrown while the initalize function from prism is taking place.
Here is a snippet from my app.xaml.cs
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
this.RegisterLocal(containerRegistry);
this.RegisterServices(containerRegistry);
this.RegisterPagesForNavigation(containerRegistry);
}
This code all executes and passes.
This is the iOS initialization
Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
PullToRefreshLayoutRenderer.Init();
LoadApplication(new App(new IosInitializer()));
return base.FinishedLaunching(app, options);
}
public class IosInitializer : IPlatformInitializer
{
public void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.Register<IUAirshipUpdate, UAirshipUpdate>();
}
}
This code also executes
The exception being thrown is an argument null exception indicating that IModuleCatelog is not present. I do not understand why it is looking for that module and can not find it. The source code on GitHub indicates that class was registered.
This issue was caused because linker behavior for IOS application was set to full and that causes issues with Unity IOC Container.
I am trying to register alert service ( message dialog) at setup.cs for this method
protected override void InitializePlatformServices() {
base.InitializePlatformServices();
Mvx.RegisterSingleton<IAlertService>(new AlertService());
}
but i also have this exception http://prntscr.com/krpbcw
For services which has implementation in native projects.
Go to Setup.cs
protected override IMvxApplication CreateApp(){
Mvx.RegisterType< IAlertService, AlertService >();
}
Know one thing, AlertService implements IAlertService
I am getting the following error when trying to open GPS settings page if GPS is not enabled (within Xamarin):
Unknown identifier: StartActivity
Unhandled Exception:
Java.Lang.NullPointerException:
Can somebody please guide where am I getting wrong?
This My Interface
namespace MyApp
{
public interface GpsSettings
{
void showGpsSettings();
}
}
This the Implementation
[assembly: Xamarin.Forms.Dependency(typeof(GpsSettingsImplementation))]
namespace MyApp.Droid
{
public class GpsSettingsImplementation : Activity, GpsSettings
{
public GpsSettingsImplementation()
{
}
public void showGpsSettings()
{
var intent = new Intent(Android.Provider.Settings.ActionLocationSourceSettings);
StartActivity(intent);
}
}
}
This is how I call my function on button click
DependencyService.Get<GpsSettings>().showGpsSettings();
An existing Activity instance has a bit of work that goes on behind
the scenes when it's constructed; activities started through the
intent system (all activities) will have a Context reference added to
them when they are instantiated. This context reference is used in the
call-chain of StartActivity.
So, the Java.Lang.NullPointerException seen after invoking
StartActivity on your Test activity instance is because the Context
inside that instance has never been set. By using the new operator to
create an activity instance you've circumvented the normal way
activities are instantiated, leaving your instance in an invalid
state!
ref: https://stackoverflow.com/a/31330999/5145530
The above error can be resolved in the following manner:
[assembly: Xamarin.Forms.Dependency(typeof(GpsSettingsImplementation))]
namespace MyApp.Droid
{
public class GpsSettingsImplementation : Activity, GpsSettings
{
public GpsSettingsImplementation()
{
}
public void showGpsSettings()
{
var intent = new Intent(Android.Provider.Settings.ActionLocationSourceSettings);
intent.SetFlags(ActivityFlags.NewTask);
Android.App.Application.Context.StartActivity(intent);
}
}
}