声明google-play-services-component的方法/错误 [英] How to/Error in declaring google-play-services-component

查看:244
本文介绍了声明google-play-services-component的方法/错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用eclipse / Java ADT捆绑包,我正在尝试让google map api工作。



参考文档中的Google地图开始运行是设置Google Play SDK>引用eclipse的项目



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



在页面底部,设置项目属性后,它表示我需要在清单文件中声明库组件



例如:

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

所以在我的Android清单,我尝试包括这个:

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

但是,Google Play服务库.jar在其名称中包含破折号,并在这些破折号显示为错误(我得到红色的阵风)。



另外,我试图将它包含在google play sdk下载(extras)附带的google地图示例项目中,所以我不是100%确定是否必须执行此步骤。



我如何解决这个问题?

解决方案

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



这里是google maps api v2的快速指南。我在办公室的项目中使用了这个。



无法实例化android.gms.maps.MapFragment



如果您在MapFragment或Google Play服务库中遇到问题,请使用此stackoverflow线程



如果您在获取SHA1指纹时遇到问题,请执行以下步骤。


  1. 如果您正在使用linux,请打开DOS命令行或终端。


  2. cd(更改目录)到Java\jdk1的目录。您的JDK 7.的7.0\bin。在我的情况下,它是C:\Program Files\Java\jdk1.7.0\bin。为了使它更容易,将该目录添加到您的系统路径。


  3. 执行您的java的keytool,并使用调试密钥库或官方密钥库。 (请参阅图片作为示例)。




通常语法是,keytool.exe -list -alias androiddebugkey -keystore[您的密钥库]-storepass android -keypass android



复制并粘贴SHA1指纹,并使用它在api控制台上生成google map api密钥。它应该是API访问,然后是Google Maps API V2。



您可以在SHA1指纹中附加应用程序包的名称。这样的东西。

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



< 。p>最后,您现在应该有你的珍贵地图API密钥,并按照我张贴的快速故障排除链接





如果您执行上述命令,JDK7默认情况下会生成SHA1。如果您使用JDK6,则会生成MD5指纹。我想你需要在命令的末尾添加-v,这样JDK6就可以给你SHA1。在这里我来说,我有JDK7所以当我添加 - v更高的IT会告诉你不同的指纹



玩得开心:D


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?

解决方案

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).

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.

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

这篇关于声明google-play-services-component的方法/错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆