You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xamarin.Forms.Maps在Android 7+设备崩溃问题求助

Xamarin.Forms Google Maps crashes on Android 7+ devices without error (works on older versions & emulators)

I'm a new Xamarin.Forms developer who built a free local app with Google Maps integration. The app runs flawlessly on all Visual Studio 2019 Android emulators and an old Android 4.3 physical device, and the publishing process went off without a hitch. However, my first user reported that the app immediately crashes with no error messages when opening the ContentPage containing the Map control on their Android 9 device. All other ContentPages that don't include the map work perfectly fine.

Since I don't have a physical Android 9 device to debug with, and all VS emulators behave normally, I set up Nox Player and created emulators for Android 5.1.1 and 7.1.2 to test:

  • The app works as expected on the Android 5 emulator
  • It crashes instantly on the Android 7 emulator (the emulator closes right away with no error prompts)

Minimal Test App Results

I created a stripped-down test app that only displays a map to isolate the issue. Here's the MainPage.xaml code:

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

The results matched my original app: it works on VS emulators, the Android 4.3 device, and Nox Android 5, but crashes on Nox Android 7.

Official Sample Test

I also tried compiling the official Microsoft Xamarin.Forms.Maps sample. After replacing the com.google.android.maps.v2.API_KEY in AndroidManifest.xml, I still ran into the exact same crash issue.

Third-Party Package Test

Originally, I was using the Xamarin.Forms.GoogleMaps third-party package for my app, and the crash behavior was identical. Even the pre-compiled sample APK provided on that package's page had the same problem.

AndroidManifest.xml Configuration

<?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>

I’ve spent hours trying to narrow down the issue but can’t figure out why this crash only occurs on newer Android versions. I’d really appreciate any insights or troubleshooting tips from fellow developers!

内容的提问来源于stack exchange,提问作者Lealan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 07:52:24