Application stops before showing anything

Hey you guys, I've got some problems, only one for now.

I deploy my application to Google Play about 2 months ago, and yesterday I received an email relating the app does not open in a device and it break before open, showing on the screen "Unfortunately, (?) Has stopped". It runs normaly in another device, but not in the "J3 (2016) android version 5.11's user".
I opened the Google Play Console, and looked for answers in ANR's menu. I found this:

java.lang.NoSuchMethodError:
at md5846bd09d5a4e74db0c2de01aa9d1e1cf.MainActivity.n_onCreate (Native Method)
at md5846bd09d5a4e74db0c2de01aa9d1e1cf.MainActivity.onCreate (MainActivity.java:30)
at android.app.Activity.performCreate (Activity.java:6609)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1134)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3113)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3275)
at android.app.ActivityThread.access$1000 (ActivityThread.java:218)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1744)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:145)
at android.app.ActivityThread.main (ActivityThread.java:7007)
at java.lang.reflect.Method.invoke (Native Method)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1199)

I'll try to reproduce this error via android emulator.
Does anybody seen this before, know how to solve and can help me?

Thank you guys.

Best Answer

Answers

  • FurnariFurnari Member ✭✭

    You tried it in another device with lollipop 5.1.1?

  • Brand00wnBrand00wn Member ✭✭

    I tried to emulate my app by Android Emulator with Lollipop 5.1.1, and I've got the same error. The debugger return me this message: "Java.Lang.LinkageError: ".

  • yelinzhyelinzh Member, Xamarin Team Xamurai

    The root cause is that you most likely have compiled a class against a different version of the class that is missing a method.

  • Brand00wnBrand00wn Member ✭✭

    After some tests here, I saw that the application only runs from Android 6.0 to up, and this error repeats in lowest versions.

  • yelinzhyelinzh Member, Xamarin Team Xamurai

    This method is estimated to be introduced for the first time in Android 6.0.

  • Brand00wnBrand00wn Member ✭✭
    edited March 29

    Ok, but... How to know which method it is? Because in the ANR's report I see a lot of methods. If I want to reformulate my application to run in a lowest android version, I have to change all of these methods that appear in ANR?

  • Brand00wnBrand00wn Member ✭✭
    edited March 29

    Guys, I have some news... Analysing my code, I noticed that if I comment, in MainActivity.cs the line thath calls RequestPermissions(), the application runs normally in lowest versions. I'll share this code above:

    protected async override void OnCreate(Bundle savedInstanceState)
            {
                TabLayoutResource = Resource.Layout.Tabbar;
                ToolbarResource = Resource.Layout.Toolbar;
                base.OnCreate(savedInstanceState);
                Xamarin.Essentials.Platform.Init(this, savedInstanceState);
                //RequestPermissions(Permission, RequestId);
                Xamarin.Forms.Forms.Init(this, savedInstanceState);
    
                LoadApplication(new App());
                var data = Intent.Data;
                if (data != null)
                {
                    <Here occours the Handler Protocol>
                }
            }
    

    And the RequestPermission() is part of Mono.Android.dll:

    public void RequestPermissions(string[] permissions, int requestCode);
            [Register("requestShowKeyboardShortcuts", "()V", "", ApiSince = 24)]
            public void RequestShowKeyboardShortcuts();
    

    Is there another way to Request this Permission?

  • Brand00wnBrand00wn Member ✭✭

    Hitted the nail on the head, JohnHair!! Permissions are only required from Android 6.0, below this, needn't it. I used a structure to verify the device's Android Version, then, if it is up to 6.0, asks permission, else, does nothing.

Sign In or Register to comment.