2

I am using eclipse/the Java ADT bundle and I am trying to get google maps api working.

Referenced in the documentation to get google maps up and running is "setting up Google Play SDK" > "Referencing a library project for eclipse"

http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject

At the very bottom of that page, after setting up the project properties, it says that I need to "declare library components in the manifest file"

For example:

<manifest>
  ...
  <application>
    ...
    <activity android:name="com.example.android.tictactoe.library.GameActivity" />
    ...
  </application>
</manifest>

so in my android manifest, I tried including this:

   <activity android:name="com.example.android.MainActivity.library.google-play-services_lib" />
   <activity android:name="com.example.android.MainActivity.library.google-play-services" />

However, the google play services library .jar has dashes included in its name, and in eclipse these dashes show up as errors (I get the red squigglies).

Also, I'm trying to include this in the google maps sample project that came with the google play sdk download (under "extras"), so I'm not 100% sure if I have to do this step.

How can I fix this?

LazerSharks
  • 3,089
  • 4
  • 42
  • 67

2 Answers2

2

At the very bottom of that page, after setting up the project properties, it says that I need to "declare library components in the manifest file"

For Maps V2, there are no such components that you need to worry about. This would only be if there were activities, services, or other components published by the library project that you were trying to use without subclassing them.

How can I fix this?

Just delete those two <activity> lines.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Hmm... but I still need to have the google maps library referenced/included right? – LazerSharks Feb 20 '13 at 23:40
  • 1
    @Gnuey: Yes, you will need to have the Play Services library project referenced from your application project. You just do not have to add any `` elements. For what it's worth, here is a sample project of my own for using Maps V2: https://github.com/commonsguy/cw-omnibus/tree/master/MapsV2/Basic – CommonsWare Feb 20 '13 at 23:43
  • I've done the referencing, but my app crashes when the page with a simple maps loads. Do you know potential problems explaining why this happens? I should not have to acquire an SHA1 fingerprint to test in demos right? I have also set up my JAVA_HOME environment variables and included the keytool and jarsigner in my PATH. – LazerSharks Feb 20 '13 at 23:53
  • @Gnuey: Use LogCat to examine the Java stack trace associated with y our crash. You will need the Maps API key for the samples. – CommonsWare Feb 20 '13 at 23:55
1

https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw

here's quick guide to google maps api v2. I used this in my project at the office.

Unable instantiate android.gms.maps.MapFragment

If you having problems with the MapFragment or google play services library use this stackoverflow thread to troubleshoot.

If you having trouble with getting your SHA1 fingerprint here's the steps.

  1. Open your DOS command line or terminal if you are using linux.

  2. cd (change directory) to the directory of Java\jdk1.7.0\bin of your JDK 7. In my case it is C:\Program Files\Java\jdk1.7.0\bin. To make it a lot easier add that directory to your system path.

  3. Execute the keytool of your java and use your debugging keystore or official keystore. (refer to the image as example).

enter image description here

Generally the syntax is, keytool.exe -list -alias androiddebugkey -keystore "[directory of your keystore]" -storepass android -keypass android

copy and paste the SHA1 fingerprint keep it and use it to generate the google map api key on the api console. It should be on API access then Google Maps API V2.

There you append the name of the package of your app in your SHA1 fingerprint. Something like this.

55:87:D6:B4:60:35:AD:CA:C8:86:84:7D:62:D2:5B:3D:18:34:EB:16;com.my.package

Finally you should have now your precious map api key and follow the quick and troubleshooting links that I posted.

enter image description here

One more thing JDK7 by default produces SHA1 if you will execute the command above. If you are using JDK6 it produces MD5 fingerprint. I think you need to add -v at the end of the command so that JDK6 will give you SHA1. In my case here I have JDK7 so when I add - v it will show you different fingerprints.

Have fun :D

Community
  • 1
  • 1
Ariel Magbanua
  • 3,083
  • 7
  • 37
  • 48
  • yeah actually in my log cat I see a lot of MapFragment issues I think. Thanks, I'll take a look! – LazerSharks Feb 21 '13 at 00:04
  • https://developers.google.com/maps/documentation/android/ for much detailed docs on this here's your best friend. You will be needing your api key on this. You can obtain it by getting your SHA1 fingerprint using your debugging or official keystore. Then use it to generate api key for your google map in your google api console. – Ariel Magbanua Feb 21 '13 at 00:09
  • Yeah, right now I'm having the most trouble getting that api key with SHA1.... all the docs on that are very confusing to me. Also, one doc said that I should be able to test without the key in eclipse as long as I had the ADT bundle and have set up environmental variables/paths, however it's just not working. – LazerSharks Feb 21 '13 at 00:14
  • 1
    You will really needing the map api key you will put it on your manifest file. Your app will run I think without or with wrong map api key but the map image won't appear. By the way I updated my post with the steps on how to obtain the SHA1 fingerprint and generate your map api key. Enjoy! :) – Ariel Magbanua Feb 21 '13 at 22:59
  • Thank you so much for your helpful answer!!! But what do I do after I navigate to "Java\jdk1.7.0\bin" (1.6.0_38 for me)? Do I then type out the code in the image? Or do I simply use it as a reference? Because I find it odd that we navigated there but in your screenshot you execute the commands from "C:\Users\thehardcoded". I tried executing from "Java\jdk1.6.0_38\bin" and I actually got an SHA1 output, but when I inserted it into the api console I got an error "invalid input". This is what I tried to input "57:C5:A9:28:22:A7:D7:98:8A:24:9D:8A:54:42:38:A7;com.example.mapdemo" – LazerSharks Feb 23 '13 at 07:21
  • Oh the one that is generated from the commands in your screenshot is the MDA5 fingerprint. The first link you provided help me figure out that I just needed to add a -v at the end of the commands to get the SHA1. I'm going to edit your answer to reflect that.... but YES!!! I finally got the SHA1 key. I can finally try to continue with the guides now. – LazerSharks Feb 23 '13 at 07:48
  • 1
    @Gnuey No it's not MD5 it is very clear in the screenshot it is SHA1 and I verified it on my api console. By default without JDK7 gives you SHA1 fingerprint, I think if you are using JDK 6 it produces MD5 fingerprint by default that might be a way of getting a SHA1 fingerprint in JDK 6. Also to make your life easier with these it is recommended to add the path of your JDK to your system path so that you can directly execute keytool.exe. Anyway good job generating it, I updated the post and added what you did for educational purposes. – Ariel Magbanua Feb 23 '13 at 10:50