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
|
-
Get the latest SDK tools
As a minimum when setting up the Android SDK, you should download the latest tools and Android platform:(nonsense! 下载你需要的版本即可)
- Open the Tools directory and select:
- Android SDK Tools
- Android SDK Platform-tools
- Android SDK Build-tools (highest version)
- 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
-
Get the support library for additional APIs
The support library is required for:
It also provides these popular 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
-
Get Google Play services for even more APIs
The Google Play services APIs provide a variety of features and services for your Android apps, such as:
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.
-
Install the packages
Once you've selected all the desired packages, continue to install:
- Click Install X packages.
- In the next window, double-click each package name on the left to accept the license agreement for each.
- 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.
Get the latest SDK tools
![](http://developer.android.com/images/sdk_manager_packages.png)
As a minimum when setting up the Android SDK, you should download the latest tools and Android platform:(nonsense! 下载你需要的版本即可)
- Open the Tools directory and select:
- Android SDK Tools
- Android SDK Platform-tools
- Android SDK Build-tools (highest version)
- 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
Get the support library for additional APIs
The support library is required for:
It also provides these popular 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
Get Google Play services for even more APIs
The Google Play services APIs provide a variety of features and services for your Android apps, such as:
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.
Install the packages
Once you've selected all the desired packages, continue to install:
- Click Install X packages.
- In the next window, double-click each package name on the left to accept the license agreement for each.
- 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:
- 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. - 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下,移到其他文件夹下即可)
- 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.
- 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之前至少运行一次(尽管你知道根本不会显示出地图)