Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – when my xamarin form app run, it’s has stopped?

Posted on November 11, 2022 By

Solution 1 :

You are missing the plugin initialization in the Android project.

using Xamarin.Forms.GoogleMaps.Android;
namespace App.Droid
{
   public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
       protected override void OnCreate(Bundle savedInstanceState)
       {
            // more stuff here...
            var platformConfig = new PlatformConfig
            {
               BitmapDescriptorFactory = new CachingNativeBitmapDescriptorFactory()
            };
            Xamarin.FormsGoogleMaps.Init(this, savedInstanceState, 
            platformConfig); // initialize for Xamarin.Forms.GoogleMaps
            }
            LoadApplication(new App());
        }
    }
}

Solution 2 :

At first, you can download the android studio and check the log in the emulator to find what type of error appears and causes the app crash.

In addition, there is already a sample in the github for this nuget package, have you tried that?

Finally, at the 4th step, you not only need to add these permissions into the AndroidManifest.xml, but also need the user to grant the dangerous permissions such as the location permission by himself.

So you can do a run-time permission check and request the permission according to the official document:https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/permissions?tabs=windows
and https://learn.microsoft.com/en-us/xamarin/essentials/permissions?tabs=android

Problem :

I create a blank app in xamarin form for Android. when i run blank app in emulator thas work exactly, but when add Xamarin.Form.GoogleMaps to my page and run in emulator show error!
error message = “Application has stopped”
I did the following to add Xamarin.Form.GoogleMaps .

1- download latest version Xamarin.Form.GoogleMaps from Nuget.

2- Add
<meta-data android_name="com.google.android.maps.v2.API_KEY" android_value="my api key" /> to AndroidManifest.xml

3- add all permission i need! list of permission
<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" />
<uses-permission android_name="android.permission.WRITE_EXTERNAL_STORAGE" />

4- add xmlns:maps="clr-namespace:Xamarin.Forms.GoogleMaps;assembly=Xamarin.Forms.GoogleMaps" to my page

5- and add <maps:Map VerticalOptions="Fill" HorizontalOptions="Fill"/>

Friends, how can I solve this problem of closing the app?

READ  [FIXED] Chipped Bottom Navigation for Java in Android Studio
Powered by Inline Related Posts

Comments

Comment posted by Jason

have you looked at the logs?

Comment posted by jafar

@Jason no, how can i see the logs?

Comment posted by Jason

look at the “Application Ouput” window in VS, or use the Android tools to view the device logs

Comment posted by jafar

@Jason I saw the logs, but since I’m a newbie, I can’t figure out where the problem is?

Comment posted by jafar

don’t find namespace

Comment posted by link

I found the code of this command in address

Android Tags:android, google-maps, xamarin, xamarin.android, xamarin.forms

Post navigation

Previous Post: [FIXED] React-native android build fails due to missing files in the gradle cache?
Next Post: Can I use Google storage instead of iCloud?

Related Posts

[FIXED] android – which user is exactly logged in so that we can fetch particular data Android
[FIXED] kotlin – Dagger 2 with ViewModel, Repository, Room and Coroutines Android
[FIXED] java – A method is not executing log.d statement Android
[FIXED] java – Find Similarity between images (Bitmap) in Android Android
[FIXED] android studio – Relative Layout, textView not showing below button? Android
[FIXED] java – Get all the documents in a collection along with the path of the document Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Quel est le fromage qui porte le nom d’une commune de Côte d’Or et qui est produit en Haute-marne ?
  • Welches ist das beste Senioren Smartphone?
  • What is ISO benefit?
  • What do red bottom shoes represent?
  • Are ultrasonic cleaners safe for electronics?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme