Unfortunately App Stopped Working

TobyKTobyK GBMember ✭✭✭

My confidence with using Xamarin Forms to build applications is growing thinner by each release.... Now I'm unable to debug the application I've been building the last two years as it won't deploy to device properly... Most of the time it hangs doing the Java.exe -sign command... or I end up wiping the app off the device and having to restart it whenever an update comes out.

When it does eventually start running after 9 attempted times - it now just ends immediately...

09-28 08:47:39.983 E/art (23752): No implementation found for void mono.android.Runtime.register(java.lang.String, java.lang.Class, java.lang.String) (tried Java_mono_android_Runtime_register and Java_mono_android_Runtime_register__Ljava_lang_String_2Ljava_lang_Class_2Ljava_lang_String_2)
09-28 08:47:39.984 D/AndroidRuntime(23752): Shutting down VM
09-28 08:47:39.984 E/AndroidRuntime(23752): FATAL EXCEPTION: main
09-28 08:47:39.984 E/AndroidRuntime(23752): Process: uk.co.touchretail_trimsm, PID: 23752
09-28 08:47:39.984 E/AndroidRuntime(23752): java.lang.UnsatisfiedLinkError: No implementation found for void mono.android.Runtime.register(java.lang.String, java.lang.Class, java.lang.String) (tried Java_mono_android_Runtime_register and Java_mono_android_Runtime_register__Ljava_lang_String_2Ljava_lang_Class_2Ljava_lang_String_2)
09-28 08:47:39.984 E/AndroidRuntime(23752): at mono.android.Runtime.register(Native Method)
09-28 08:47:39.984 E/AndroidRuntime(23752): at md51558244f76c53b6aeda52c8a337f2c37.FormsAppCompatActivity.(FormsAppCompatActivity.java:26)
09-28 08:47:39.984 E/AndroidRuntime(23752): at java.lang.Class.newInstance(Native Method)
09-28 08:47:39.984 E/AndroidRuntime(23752): at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
09-28 08:47:39.984 E/AndroidRuntime(23752): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)
09-28 08:47:39.984 E/AndroidRuntime(23752): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2781)
09-28 08:47:39.984 E/AndroidRuntime(23752): at android.app.ActivityThread.-wrap12(ActivityThread.java)
09-28 08:47:39.984 E/AndroidRuntime(23752): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1508)
09-28 08:47:39.984 E/AndroidRuntime(23752): at android.os.Handler.dispatchMessage(Handler.java:102)
09-28 08:47:39.984 E/AndroidRuntime(23752): at android.os.Looper.loop(Looper.java:241)
09-28 08:47:39.984 E/AndroidRuntime(23752): at android.app.ActivityThread.main(ActivityThread.java:6274)
09-28 08:47:39.984 E/AndroidRuntime(23752): at java.lang.reflect.Method.invoke(Native Method)
09-28 08:47:39.984 E/AndroidRuntime(23752): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
09-28 08:47:39.984 E/AndroidRuntime(23752): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Its difficult enough to do the work that I've been requested to do, but now its just impossible to get any work done...

Best Answer

Answers

  • TobyKTobyK GBMember ✭✭✭

    @NMackay I'm managing to run the app in the simulator - so I know its not my app that's the issue. I'm bang up to date with VS, so the 'very unstable for XF' v15.8.5 - I keep updating as soon as they release them - as I'm still waiting for the debugging tooltip issues to be resolved as well... (Twisties don't open up and allow you to view object properties). I mean it can't be easy to get this right for everyone all the time but they should at least do some testing before they publish stuff (Microsoft that is)...

    For further info - I'm deploying Android 18 to 23 (as 24 and upwards a part of the app that allow user to download & install the app stop working due to the permission changes, so I'm stuck deploying 23 for now).

    I haven't got the time to 'clean/re-install' the IDE as that wipes out half a day these days. so I'll make do with the sim for now.

  • NMackayNMackay GBInsider, University mod

    @TobyK

    Just be aware from October onwards if your deploying apps to GooglePlay they will have to target 8.0 (Oreo) minimum so you'll have to sort these permission issues if your deploying to the store.

    Had to make a bunch of permissions because permissions such as Read Phone State are deemed protected/dangerous and even defining them in the manifest is not enough, your app will have to check for and request permissions at runtime, unfortunately the Permissions pluggin doesn't handle this (at time of writing this) so I had to write my own checks in certain scenarios.

  • TobyKTobyK GBMember ✭✭✭

    @NMackay

    Yes I was aware of the target changes which is when I found out about the permission changes when I updated the target on my android app. I'm not expert on Android and I found out that permissions plugin (James Montag's) didn't work for me either - thus I ended up rolling it back to 23 - as described here: https://forums.xamarin.com/discussion/comment/347216

  • JohnHardmanJohnHardman GBUniversity mod

    @NMackay said:
    Just be aware from October onwards if your deploying apps to GooglePlay they will have to target 8.0 (Oreo) minimum so you'll have to sort these permission issues if your deploying to the store.

    Excuse the stroll off-topic... I know why Google will be doing that, but for the millions of people worldwide with old devices that cannot upgrade, there are plenty of other app stores that presumably will not be enforcing an Oreo minimum. The time has come to have multiple Android projects, will one or more shared projects for code that is common. As per a suggestion by @batmaci , it's a good idea even if the only other Android-ish target is Amazon Fire.

  • NMackayNMackay GBInsider, University mod

    Well the app has to target that API level but you can still install on older devices but you have to guard against features missing on older API's or am I missing something?

  • JohnHardmanJohnHardman GBUniversity mod

    @NMackay said:
    Well the app has to target that API level but you can still install on older devices but you have to guard against features missing on older API's or am I missing something?

    Ah, no that was just me misinterpreting your post. Late night last night ;-)

  • NMackayNMackay GBInsider, University mod

    Well the app has to target that API level but you can still install on older devices but you have to guard against features missing on older API's or am I missing something?> @JohnHardman said:

    @NMackay said:
    Well the app has to target that API level but you can still install on older devices but you have to guard against features missing on older API's or am I missing something?

    Ah, no that was just me misinterpreting your post. Late night last night ;-)

    Well the weekend unofficially begins on Thursday night :)

  • HarshithaLSHarshithaLS USMember ✭✭

    Request runtime permission for Marshmallow and above

    The Target Android version should be set to Oreo. Once the update is done, even on setting permission in "Required permission" it's not setting the permission on release.

    Solution:

    Explicit runtime permission should be requested for versions 23 and above.
    For version below 23, the application will handle it.

    in MainActivity.cs file, add below code in OnCreate existing method

      string[] PermissionsArray = null;
    
    protected override void OnCreate(Bundle bundle)
            {
                    TabLayoutResource = Resource.Layout.Tabbar;
                    ToolbarResource = Resource.Layout.Toolbar;
    
                    base.OnCreate(bundle);
    
                    global::Xamarin.Forms.Forms.Init(this, bundle);
    
                    LoadApplication(new App());
    
                    Initializer.Initialize();
                    updateNonGrantedPermissions();
    
                    try
                    {
                        if (PermissionsArray != null && PermissionsArray.Length > 0)
                        {
    //Check permission for Marshmallow and above, and request runtime permission
                            if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
                            {
                                ActivityCompat.RequestPermissions(this, PermissionsArray, 0);
                            }
                        }
                    }
                    catch(Exception oExp)
                    {
    
                    }
    }
    
    //To add permissions which the application does not have. By performing a check of granted or denied permissions.
    //Below is an example to check the permission for the microphone, storage, phone state.
    
     private void updateNonGrantedPermissions()
            {
                try
                {
                    List<string> PermissionList = new List<string>();
    
                    if (ContextCompat.CheckSelfPermission(Forms.Context, Manifest.Permission.RecordAudio) != (int)Android.Content.PM.Permission.Granted)
                    {
                        PermissionList.Add(Manifest.Permission.RecordAudio);
                    }
                    if (ContextCompat.CheckSelfPermission(Forms.Context, Manifest.Permission.WriteExternalStorage) != (int)Android.Content.PM.Permission.Granted)
                    {
                        PermissionList.Add(Manifest.Permission.WriteExternalStorage);
                    }
                    if (ContextCompat.CheckSelfPermission(Forms.Context, Manifest.Permission.ReadPhoneState) != (int)Android.Content.PM.Permission.Granted)
                    {
                        PermissionList.Add(Manifest.Permission.ReadPhoneState);
                    }
                    PermissionsArray = new string[PermissionList.Count];
    
    //Adds permissions which are denied by application
                    for (int index = 0; index < PermissionList.Count; index++)
                    {
                        PermissionsArray.SetValue(PermissionList[index], index);
                    }
                }
                catch(Exception oExp)
                {
    
                }
            }
    
Sign In or Register to comment.