Android Gradle 如何为 Android Google APIs 4.2.2 构建而不是为 Android 4.2.2 [英] Android Gradle How to build for Android Google APIs 4.2.2 not for Android 4.2.2

查看:27
本文介绍了Android Gradle 如何为 Android Google APIs 4.2.2 构建而不是为 Android 4.2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Is it possible to build for Android Google APIs SDK instead of the general Android SDK with gradle?

I need the Google Maps APIs in my project therefore I need to change the build target I can find only samples with the build version "17" compileSdkVersion 17 buildToolsVersion '17.0.0'

Any idea how to do that?

解决方案

i figured it out:

1) use the Android SDK Manager and get the Google APIs for the android versions you want (start it from Android Studio, it's seperate from your old sdk manager if you used eclipse before)

2)

  • Go to "File > Project Structure > SDKs"
  • click the plus sign and select "Android SDK"
  • a popup will appear, navigate to your Android Studio installation folder and select the "sdk" subfolder
  • another popup will appear: select "Google APIs (#.#.#)"

3) In the same Project Structure window: select "Android #.#.# Google APIs"the Project SDK click Apply/OK

4) Now in your build.gradle files replace

android {
    ...
    compileSdkVersion 17
    ...
}

with

android {
    ...
    compileSdkVersion "Google Inc.:Google APIs:17"
    ...
}

6) restart Android Studio

this did it for me for google apis 16. If you're still having troubles:

  • Go to "File > Project Structure > SDKs"
  • Select your Google API > classpath
  • Make sure the Google APIs jar files are in there (e.g. Android Studio/sdk/add-ons/addon-google_apis-google-16/libs/maps.jar)
  • if not add them manually (had to do this for apis 17)
  • restart Android Studio

这篇关于Android Gradle 如何为 Android Google APIs 4.2.2 构建而不是为 Android 4.2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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