Ubuntu 12.04 下Google Maps Android API v2

Install the Android SDK

下载SDK的时候可能无法更新,

这个可能是网络问题,国内连google服务器经常连不上。

尝试用下面办法试下:(亲测可行)
1.上图SDK Manager 的 Tools ->Options打开SDK Manager的Settings,

   选中“Force https://… sources to be fetched using http://…”,

   强制使用http协议。

2.改hosts文件。

   Windows在C:\WINDOWS\system32\drivers\etc目录下,

   Linux用户打开/etc/hosts文件,   

   打开文件后添加以下内容:

1
2
3
#android更新
203.208.46.146 dl.google.com
203.208.46.146 dl-ssl.google.com

  1. Get the latest SDK tools

    As a minimum when setting up the Android SDK, you should download the latest tools and Android platform:(nonsense! 下载你需要的版本即可)

    1. Open the Tools directory and select:
      • Android SDK Tools
      • Android SDK Platform-tools
      • Android SDK Build-tools (highest version)
    2. Open the first Android X.X folder (the latest version) and select: 
      • SDK Platform
      • A system image for the emulator, such as 
        ARM EABI v7a System Image
  2. Get the support library for additional APIs

    The Android Support Library provides an extended set of APIs that are compatible with most versions of Android.

    Open the Extras directory and select:

    • Android Support Repository
    • Android Support Library

     

     

  3. Get Google Play services for even more APIs

    To develop with Google APIs, you need the Google Play services package:

    Open the Extras directory and select:

    • Google Repository
    • Google Play services

    Note: Google Play services APIs are not available on all Android-powered devices, but are available on all devices with Google Play Store. To use these APIs in the Android emulator, you must also install the the Google APIs system image from the latest Android X.X directory in the SDK Manager.

  4. Install the packages

    Once you've selected all the desired packages, continue to install:

    1. Click Install X packages.
    2. In the next window, double-click each package name on the left to accept the license agreement for each.
    3. Click Install.

    The download progress is shown at the bottom of the SDK Manager window. Do not exit the SDK Manager or it will cancel the download.


Install and configure the Google Play services SDK

To make the Google Play services APIs available to your app:

  1. Copy the library project at <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/ to the location where you maintain your Android app projects.
  2. Import the library project into your Eclipse workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it. (windowls下这样做没问题,但Ubuntu 12.04 下这样做会提示 Invalid project description,解决方法:不要奖上述lib放在workspace下,移到其他文件夹下即可)
  3. In your app project, reference Google Play services library project. See Referencing a Library Project for Eclipse for more information on how to do this.

    Note: You should be referencing a copy of the library that you copied to your development workspace—you should not reference the library directly from the Android SDK directory.

  4. After you've added the Google Play services library as a dependency for your app project, open your app's manifest file and add the following tag as a child of the <application> element:
    <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        

Once you've set up your project to reference the library project, you can begin developing features with theGoogle Play services APIs.


遇到的问题:

如果安装官网的指示,程序可以运行并显示网格但不显示地图的话,很可能是Key生成过程中出错。

一般情况在Eclipse--Pref中可以看到SHA1的值,如果非要从命令行获取的话,可参考:http://stackoverflow.com/questions/5337611/unrecognized-option-keypass-while-getting-md5-fingerprint-of-debug-certificate

程序至少要运行一次才具有debug certificate,而这是申请key所需要的,所以再申请key之前至少运行一次(尽管你知道根本不会显示出地图)



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值