Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable

$
0
0

I have downloaded the latest xamarin samples and opend Maps And Locations Demo V3.

From this project i run the SampleMapDemo. (Not the SampleMapDemoFroyo). I have registered my fingerprint with google and got a valid working API Key. When i run the sample map demo i see all maps including the AXML demo. I get no errors.

Now i have add the google play service component in my own project true the folder Components => Get more components. I have added a MapsView:

<?xml version="1.0" encoding="utf-8"?>


And an MapsActivity:

public class MapActivity : Activity { private GoogleMap _googleMap;

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        SetContentView(Resource.Layout.view_map);
        InitializeMap();
    }

    public void InitializeMap()
    {
        if (_googleMap == null)
        {
            _googleMap = ((MapFragment)FragmentManager.FindFragmentById(Resource.Id.map)).Map;

            // check if map is created successfully or not
            if (_googleMap == null)
            {
                Toast.MakeText(ApplicationContext, "Sorry! unable to create maps", ToastLength.Short).Show();
            }
        }

        try
        {
            _googleMap.MapType = GoogleMap.MapTypeNormal;
            _googleMap.MyLocationEnabled = true;
            _googleMap.UiSettings.MyLocationButtonEnabled = true;
            _googleMap.UiSettings.ZoomGesturesEnabled = true;
            _googleMap.UiSettings.ZoomControlsEnabled = true;
            _googleMap.UiSettings.CompassEnabled = true;
            _googleMap.UiSettings.RotateGesturesEnabled = true;
            _googleMap.UiSettings.SetAllGesturesEnabled(true);

            var locations = GetLocations();
            for (int i = 0; i < locations.Count; i++)
            {
                var location = new LatLng(locations[i].Latitude, locations[i].Longitude);
                CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                builder.Target(location);
                builder.Zoom(15);
                builder.Bearing(100);
                CameraPosition cameraPosition = builder.Build();
                CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);
                _googleMap.AnimateCamera(cameraUpdate);

                var marker = new MarkerOptions();
                marker.SetPosition(new LatLng(locations[i].Latitude, locations[i].Longitude));
                marker.SetTitle("Hello Maps");
                marker.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueMagenta));
                _googleMap.AddMarker(marker);
            }
        }
        catch (AndroidException e)
        {
            e.PrintStackTrace();
        }
    }

    protected override void OnResume()
    {
        base.OnResume();
        InitializeMap();
    }

    private List<MapLocation> GetLocations()
    {
        var list = new List<MapLocation>
        {
            new MapLocation(52.353423, 4.850194),
            new MapLocation(52.353333, 4.850327)
        };
        return list;
    }
}


public class MapLocation
{
    public string Title { get; set; }
    public double Latitude { get; set; }
    public double Longitude { get; set; }

    public MapLocation() { }

    public MapLocation(double latitude, double longitude)
    {
        Latitude = latitude;
        Longitude = longitude;
    }
}

When i run my project i get the following error:

02-04 15:19:56.281 I/MonoDroid(13000): UNHANDLED EXCEPTION: Java.Lang.NoClassDefFoundError: Exception of type 'Java.Lang.NoClassDefFoundError' was thrown. 02-04 15:19:56.281 I/MonoDroid(13000): at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00064] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/56127394/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:194 02-04 15:19:56.281 I/MonoDroid(13000): at Android.Views.LayoutInflater.Inflate (int,Android.Views.ViewGroup) [0x00043] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/56127394/source/monodroid/src/Mono.Android/platforms/android-18/src/generated/Android.Views.LayoutInflater.cs:575 02-04 15:19:56.281 I/MonoDroid(13000): at Cirrious.MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.CommonInflate (int,Android.Views.ViewGroup,Cirrious.MvvmCross.Binding.Droid.Binders.IMvxLayoutInfactorFactory) 02-04 15:19:56.281 I/MonoDroid(13000): at Cirrious.MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.BindingInflate (int,Android.Views.ViewGroup) 02-04 15:19:56.281 I/MonoDroid(13000): at Cirrious.MvvmCross.Binding.Droid.BindingContext.MvxBindingContextOwnerExtensions.BindingInflate (Cirrious.MvvmCross.Binding.BindingContext.IMvxBindingContextOwner,int,Android.Views.ViewGroup) 02-04 15:19:56.281 I/MonoDroid(13000): at Cirrious.MvvmCross.Droid.Views.MvxActivity.SetContentView (int) 02-04 15:19:56.281 I/MonoDroid(13000): at TroostwijkAuctions.Client.Droid.Views.Activities.MapActivity.OnViewModelSet () [0x00008] in c:\DiskNathalie\TFS\Auctions\Client\Develop\TroostwijkAuctions.Client.Droid\Views\Activities\MapActivity.cs:48 In mgmain JNI_OnLoad 02-04 15:19:56.281 I/MonoDroid(13000): at Cirrious.MvvmCross.Droid.Views.MvxActivity.set_ViewModel (Cirrious.MvvmCross.ViewModels.IMvxViewModel) 02-04 15:19:56.281 I/MonoDroid(13000): at Cirrious.MvvmCross.Views.MvxViewExtensionMethods.OnViewCreate (Cirrious.MvvmCross.Views.IMvxView,System.Func

1<Cirrious.MvvmCross.ViewModels.IMvxViewModel>) <IL 0x0003f, 0x0023f>
02-04 15:19:56.281 I/MonoDroid(13000): at Cirrious.MvvmCross.Droid.Views.MvxActivityViewExtensions.OnViewCreate (Cirrious.MvvmCross.Droid.Views.IMvxAndroidView,Android.OS.Bundle) <IL 0x00073, 0x00337>
02-04 15:19:56.281 I/MonoDroid(13000): at Cirrious.MvvmCross.Droid.Views.MvxActivityAdapter.EventSourceOnCreateCalled (object,Cirrious.CrossCore.Core.MvxValueEventArgs
1<Android.OS.Bundle>) 02-04 15:19:56.281 I/MonoDroid(13000): at (wrapper delegate-invoke) System.EventHandler1<Cirrious.CrossCore.Core.MvxValueEventArgs1<Android.OS.Bundle>>.invoke_void__this___object_TEventArgs (object,Cirrious.CrossCore.Core.MvxValueEventArgs
1<Android.OS.Bundle>) <0x00067>
02-04 15:19:56.281 I/MonoDroid(13000): at Cirrious.CrossCore.Core.MvxDelegateExtensionMethods.Raise<Android.OS.Bundle> (System.EventHandler
1<Cirrious.CrossCore.Core.MvxValueEventArgs`1<Android.OS.Bundle>>,object,Android.OS.Bundle) <0x000c3> 02-04 15:19:56.281 I/MonoDroid(13000): at Cirrious.CrossCore.Droid.Views.MvxEventSourceActivity.OnCreate (Android.OS.Bundle) 02-04 15:19:56.281 I/MonoDroid(13000): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/56127394/source/monodroid/src/Mono.Android/platforms/android-18/src/generated/Android.App.Activity.cs:2178 02-04 15:19:56.281 I/MonoDroid(13000): at (wrapper dynamic-method) object.81e504a5-aa23-4386-a21f-84a5edc9a48f (intptr,intptr,intptr) 02-04 15:19:56.281 I/MonoDroid(13000): 02-04 15:19:56.281 I/MonoDroid(13000): --- End of managed exception stack trace --- 02-04 15:19:56.281 I/MonoDroid(13000): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable 02-04 15:19:56.281 I/MonoDroid(13000): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source) Unhandled Exception:

Java.Lang.NoClassDefFoundError: Loading...

The program 'Mono' has exited with code 0 (0x0).

I have tried anything i could think off but no luck. Also google did not come with any answer.

Does anyone know what i must do to fix this issue?

Thanks a lot


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>