How can I create an Android application in Android Studio that uses the Google Maps Api v2?

本文指导您如何在Android Studio中导入并配置Google Play Services,解决地图项目运行时遇到的未知引用错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


1) I took maps project from the Google Play Services samples and copied that to the separate directory. That is going to be our MapsApiV2 project we will be trying to run. On my Mac it was located at <sdk_location>/extras/google/google_play_services/samples I placed it to the~/Work/stack/

2) Copied google-play-services_lib project directory to the same place (~/Work/stack), so my working directory looks like this. Btw, lib project is located at<sdk_location>/extras/google/google_play_services/libproject



3) Now let's open Android Studio. On welcome screen press Import Project and import our mapsproject from ~/Work/stack/maps. Now we see a lot of complaints about unknown reference to GMS library:



4) Now we need to add Google Play Service as a reference library. Going to View -> Open Module Settings

5) On the Modules tab, click + button and select Import Module and import your GooglePlayServices lib. I didn't change anything in the wizards, so clicked Next all the way to the end:



6) Now you need to reference this imported library. Open this screen again (go to View -> Module Settings). Make sure you have your maps project and Dependency tab selected. Click + to add a dependency and select Library. Choose your imported library there:



7) Now we can see that it is not complaining about GMS library, but still complaining about support library:



8) Let's fix it. I have my support library located at <sdk location>/extras/android/support/v13/android-support-v13.jar. So let's try to add it to our workspace. Go to View -> Open Module Settings and select Libraries tab. Select + -> Javaand select support library:


9) Now it is going to ask you which project to add this lib to, so make sure you have selected your mapsproject:



10) At this point code should compile w/o problems. Just make sure you are targeting the right SDK version in Manifest.

转载地址:http://stackoverflow.com/questions/16596715/how-can-i-create-an-android-application-in-android-studio-that-uses-the-google-m?rq=1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值