accessing google apis in the new intel x86 android emulator

谁说胖子不能爱 提交于 2019-12-03 04:56:03

问题


I just tried to run my company's app in the new x86 android emulator, but our app relies on the google maps API, and that is not available in the x86 system image that google provided with android sdk release 17. My intuition says the answer is no, but is it possible to get the google apis into this system image somehow? If not, is there any way to conditionally not use a system API like google maps if it isn't present on the device/emulator that you are currently using?


回答1:


My intuition says the answer is no, but is it possible to get the google apis into this system image somehow?

There is but the one image, so if Maps are not there, then Maps are not there. You cannot add the Maps add-on to an existing emulator image, except perhaps via software piracy, as the other answer on this question advocates.

If not, is there any way to conditionally not use a system API like google maps if it isn't present on the device/emulator that you are currently using?

Absolutely!

Step #1: Add android:required="false" to your <uses-library> element for Google Maps, so you can install the app

Step #2: Sometime before you start trying to use Google Maps, see if you have Maps-related classes using Class.forName()

For example, in this book sample project, my launcher activity sees if we have MapActivity, and if we do, it passes control to a MapActivity instance, and if not shows a Toast.




回答2:


You have to create a system image with Googles libs and permissions. See http://38911bytes.blogspot.de/2012/03/how-to-use-google-maps-api-in-android.html for a cookbook to create and use such an image.




回答3:


As of API 19 (Android 4.4), it looks like Google itself is now providing the Google APIs package for x86.

Package Description
Google APIs (x86 System Image), Android API 19, revision 2
By Google Inc.
Android x86 + Google APIs
Requires SDK Platform Android API 19

Archive Description
Archive for any OS
Size: 195.5 MiB
SHA1: 0fb71d18800064c96a5645166e2ae666275a1e59



回答4:


Note that the Android 4.3 x86 system image should now have the Google APIs inside of it. It was released on 3/4/2014.

http://www.androidpolice.com/2014/03/04/developer-psa-google-and-intel-release-x86-emulator-image-with-google-apis-for-the-first-time/



来源:https://stackoverflow.com/questions/9847111/accessing-google-apis-in-the-new-intel-x86-android-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!