Android的摇篮如何构建Android版谷歌API的4.2.2没有为Android 4.2.2摇篮、Android、版谷歌、API

2023-09-06 00:08:52 作者:昨日青空

是否有可能建立一般的Andr​​oid SDK有摇篮的谷歌Android SDK的API,而不是?

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

我需要在我的项目的谷歌地图API,因此我需要改变的构建目标 我能找到的内部版本号17只样本 compileSdkVersion 17 buildToolsVersion '17 .0.0

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?

推荐答案

我想通了:

1)使用Android SDK管理器,并得到了谷歌的API,你要(从Android的工作室启动了Android版本,这是从旧的SDK经理单独的,如果你使用了Eclipse之前)

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)

进入文件>项目结构>软件开发工具包 点击加号,然后选择Android SDK中 在弹出框将出现,导航到你的Andr​​oid Studio安装文件夹,然后选择SDK子文件夹 在弹出另一个会出现:选择谷歌的API(。###)

3)在同一项目结构窗口:选择。Android的###谷歌的API项目SDK单击应用/确定

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

4)现在,在你的build.gradle文件替换

4) Now in your build.gradle files replace

android {
    ...
    compileSdkVersion 17
    ...
}

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

6)重新启动机器人工作室

6) restart Android Studio

这为我做了谷歌的API 16。 如果你还有问题:

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

进入文件>项目结构>软件开发工具包 选择您的谷歌API>类路径 确保该谷歌API的jar文件都在那里 (如Android的工作室/ SDK /插件/插件,google_apis - 谷歌-16 /库/ maps.jar) 如果不手动添加(不得不这样做原料药17) 在重启机器人工作室 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