Xamarin.Forms.Maps crashed on android 7+

415 Views Asked by At

i am a beginner xamarin.forms developer and i have developed some free application with google maps for my town.

The application works perfectly on all Visual Studio's (2019) android emulators and even on my old phone (android 4.3).

Publication of the application also was successful.

However the first user who installed the application on his phone (android 9) reported me that the application is crashed. Just crashed at moment of displaying (trying) of map without any error message. But any others (without map) "ContentPage" of the application work as it should. Crash happened only when user tries open ContentPage with the map control.

Because i haven't the real android 9 device (and on all visual studio's android emulators the application is works), i installed the Nox Player:
https://www.bignox.com/
and created 2 available emulators: android 5.1.1 and android 7.1.2
Results: the application successful works on android 5 and crashed on android 7 (together with the android 7 emulator - the emulator program just close without any error message).

Ok. I have created a simplest test xamarin forms map application - just show map and nothing more.

MainPage.xaml:

<ContentPage.Content>
    <map:Map />
</ContentPage.Content>

The same story: works on all visual studio's android emulators, works an my old android 4.3 device, works on nox-player android 5 and crashed on nox android 7!

Then, i tried just to compile a samples from microsoft documentation. For example:
https://learn.microsoft.com/en-us/samples/browse/?products=xamarin&term=Xamarin.Forms.Maps
All these samples are placed here:
https://github.com/xamarin/xamarin-forms-samples/tree/master/WorkingWithMaps
I just downloaded the solution, substitute my "com.google.android.maps.v2.API_KEY" to AndroidManifest.xml and compiled it. No more actions.
Results: The absolutely same behavior.

To be more precise, initially I used the Xamarin.Forms.GoogleMaps package: https://github.com/amay077/Xamarin.Forms.GoogleMaps
with same results.

More over on this page there is the link on already compiled apk with samples: https://install.appcenter.ms/users/okuokuoku/apps/xfgooglemapsample/distribution_groups/trial
Result: the same.

Please, who knows what the reason is?

More info: Android app options pg1 Android app options pg2 Android app options pg3

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.comscreen.App1" android:installLocation="internalOnly">
    <uses-sdk android:minSdkVersion="22" android:targetSdkVersion="28" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:label="App1.Android" android:usesCleartextTraffic="true" android:icon="@mipmap/launcher_foreground">
        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MY_API_KEY_SORRY_FOR_HIDING" />
    </application>
</manifest>
1

There are 1 best solutions below

9
On

As you've not provided any erorr code, i can only suspect 2 reasons:

  1. Maybe map requires some kind of permission in new versions of android ? Check again
  2. While creating APK, have you checked all architectures ? Under Android Options -> Advanced -> Supported Architectures -> Select all architectures. More info here: https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/cpu-architectures?tabs=windows