Joseph Anderson
Joseph Anderson

Reputation: 4144

package com.google.android.maps does not exist

I am trying to use Google Maps with Mono for Android on IOS. I have performed these steps:

  1. I installed the Android SDK and Google Maps API at /Users/JosephAnderson/Android-SDKs

  2. I created an emulator just for Google Maps, which targets API 8 for Google Maps API

  3. I added a reference to the Android.GoogleMaps assembly from Xamarin.

I receive this error when deploying to the emulator:

package com.google.android.maps does not exist

Upon adding the SDK to Developer/SDKs/android-sdk-mac_x86 and adding this to my assembly.cs file:

[assembly:Android.App.UsesLibrary (Name = "com.google.android.maps")]

I added map.jar to the root directory of my android project and set its build type to AndroidJavaLibrary.

My project will build, but I get this error on my device:

Java.Lang.NoClassDefFoundError: menufinderan.MyMapActivity
  at Android.Runtime.JNIEnv.FindClass (System.String classname) [0x00087] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.2.5-branch/6cbc40e0/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:275
  at Android.Runtime.JNIEnv.FindClass (System.Type type) [0x00009] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.2.5-branch/6cbc40e0/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:233
  --- End of managed exception stack trace ---
  java.lang.NoClassDefFoundError: menufinderan.MyMapActivity
    at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
    at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:29)
    at android.view.View.performClick(View.java:2485)
    at android.view.View$PerformClick.run(View.java:9089)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:3806)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
    at dalvik.system.DexFile.defineClass(Native Method)
    at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:207)
    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:200)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    ... 13 more

This error only occurs when inheriting from MapActivity.

Am I forgetting something?

Upvotes: 2

Views: 4632

Answers (2)

rams
rams

Reputation: 6791

Xamarin IDE offers an easier way

  1. From the Tools menu, select Open AVD Manager
  2. From the Tools menu of the Android Virtual Device Manager app, select Manage SDK..
  3. For each of the Android SDK you are targeting, check the "Google APIs" checkbox and install the packages.

You should now have the Google Maps SDK installed.

Upvotes: 2

Joseph Anderson
Joseph Anderson

Reputation: 4144

I did these steps to resolve the issue:

In terminal, type these commands:

defaults write com.apple.Finder AppleShowAllFiles TRUE

killall Finder

Navigate to this folder:

/Users/josephanderson/Library/Developer/Xamarin/android-sdk-mac_x86

Install the Google Maps API here ( go to the tools folder and click Android. Follow the rest of their steps.) When complete, the Google Maps API will exist in the add-ons folder.

Copy this file to Users/josephanderson from

/Users/[USERNAME]/.local/share/Xamarin/Mono for Android/debug.keystore

Copy paste this code into terminal:

keytool -list -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android

Upvotes: 1

Related Questions