I am trying to add google maps support to my android app. As I create whole application layout in code, I would like to create also the map object in code. This is class that should handle OnMapReady callback function.
public class MapReader : Java.Lang.Object, IOnMapReadyCallback
{
private LayoutBuilder layoutBuilder;
public MapReader(LayoutBuilder lb)
{
layoutBuilder = lb;
}
public void OnMapReady(GoogleMap googleMap)
{
layoutBuilder.OnMapLoaded(googleMap);
}
}
This is critical part of code creating the layout.
MapView mapView=new MapView(context);
mapView.LayoutParameters = layoutParams;
linearLayout.AddView(mapView);
mapReader = new MapReader(this);
mapView.GetMapAsync(mapReader);
The problem is that I get no error/exception. The OnMapReady function is never called and the screen is just empty. What can be wrong or how can I get additional info about such a behavior? I tried to follow steps from this video. In output window I tried to find lines that could help:
Loaded assembly: /storage/emulated/0/Android/data/AlienChessAndroid.AlienChessAndroid/files/.__override__/Xamarin.GooglePlayServices.Base.dll [External]
Loaded assembly: /storage/emulated/0/Android/data/AlienChessAndroid.AlienChessAndroid/files/.__override__/Xamarin.GooglePlayServices.Basement.dll [External]
Loaded assembly: /storage/emulated/0/Android/data/AlienChessAndroid.AlienChessAndroid/files/.__override__/Xamarin.GooglePlayServices.Maps.dll [External]
There are a few lines in output window that don't look good but the application runs.
AOT module 'Mono.Android.dll.so' not found: dlopen failed: library "/data/app/AlienChessAndroid.AlienChessAndroid-1/lib/arm/libaot-Mono.Android.dll.so" not found
AOT module '/storage/emulated/0/Android/data/AlienChessAndroid.AlienChessAndroid/files/.__override__/Xamarin.Android.Support.v4.dll.so' not found: dlopen failed: library "/data/app/AlienChessAndroid.AlienChessAndroid-1/lib/arm/libaot-Xamarin.Android.Support.v4.dll.so" not found
AOT module '/Users/builder/data/lanes/4009/3a62f1ea/source/monodroid/builds/install/mono-armv7/lib/mono/aot-cache/arm/Xamarin.Android.Support.v4.dll.so' not found: dlopen failed: library "/data/app/AlienChessAndroid.AlienChessAndroid-1/lib/arm/libaot-Xamarin.Android.Support.v4.dll.so" not found
This is my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="AlienChessAndroid.AlienChessAndroid" android:versionCode="1" android:versionName="1.0" android:installLocation="preferExternal">
<uses-sdk android:minSdkVersion="22" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application android:label="Alien Chess" android:icon="@drawable/Alien" android:largeHeap="true">
<meta-data android:name="com.google.android.gms.version" android:value="2" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyAmxxxxxxxxxxxxxxxxxxxxxxxxx" />
</application>
UPDATE:
I added checking for google services availability as is shown here and it returns ConnectionResult.Success.
GoogleApiAvailability gaa=GoogleApiAvailability.Instance;
int resultCode=gaa.IsGooglePlayServicesAvailable(context);
if (resultCode ==ConnectionResult.Success)
{
...
}
After reading this question I changed the line
<meta-data android:name="com.google.android.gms.version" android:value="2" />
for
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
Nothing changed.