要通过使用谷歌地图API的Android V2创建Android应用程序 [英] To Create Android Application by using Google Maps Android API v2
问题描述
我想建立它使用谷歌地图API的Android V2的Android应用程序。于是,我跟着链接 - <一个href=\"https://developers.google.com/maps/documentation/android/start#specify_settings_in_the_application_manifest\"相对=nofollow>链接。
继在链接的步骤prescribed,我能够生成API密钥。而且完成这些步骤后,我试着运行应用程序。我面对下面的错误。
I want to build an Android Application which uses Google Maps Android API v2. So, I followed the link -Link. Following the steps prescribed in the link, I am able to generate the API key. Further after completing the steps i tried to run the app. I faced following error.
04-05 10:01:56.442: E/AndroidRuntime(6170): FATAL EXCEPTION: main
04-05 10:01:56.442: E/AndroidRuntime(6170): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.task/com.example.task.MainActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2142)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2167)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.ActivityThread.access$600(ActivityThread.java:134)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.os.Looper.loop(Looper.java:150)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.ActivityThread.main(ActivityThread.java:4831)
04-05 10:01:56.442: E/AndroidRuntime(6170): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 10:01:56.442: E/AndroidRuntime(6170): at java.lang.reflect.Method.invoke(Method.java:511)
04-05 10:01:56.442: E/AndroidRuntime(6170): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-05 10:01:56.442: E/AndroidRuntime(6170): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-05 10:01:56.442: E/AndroidRuntime(6170): at dalvik.system.NativeStart.main(Native Method)
04-05 10:01:56.442: E/AndroidRuntime(6170): Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-05 10:01:56.442: E/AndroidRuntime(6170): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:257)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.Activity.setContentView(Activity.java:1867)
04-05 10:01:56.442: E/AndroidRuntime(6170): at com.example.task.MainActivity.onCreate(MainActivity.java:14)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.Activity.performCreate(Activity.java:5008)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
04-05 10:01:56.442: E/AndroidRuntime(6170): ... 11 more
04-05 10:01:56.442: E/AndroidRuntime(6170): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.Fragment.instantiate(Fragment.java:584)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.Fragment.instantiate(Fragment.java:552)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.Activity.onCreateView(Activity.java:4656)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
04-05 10:01:56.442: E/AndroidRuntime(6170): ... 21 more
04-05 10:01:56.442: E/AndroidRuntime(6170): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
04-05 10:01:56.442: E/AndroidRuntime(6170): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
04-05 10:01:56.442: E/AndroidRuntime(6170): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-05 10:01:56.442: E/AndroidRuntime(6170): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-05 10:01:56.442: E/AndroidRuntime(6170): at android.app.Fragment.instantiate(Fragment.java:574)
04-05 10:01:56.442: E/AndroidRuntime(6170): ... 24 more
错误可能是因为在 com.google.android.gms.maps.MapFragment 包中的main.xml中的。
我有 com.google.android.gms 包在我的DUT,但没能找到的 com.google.android.gms.maps.MapFragment 。我怎么能知道这个包是否在我的DUT与否,也是该如何解决的错误。
Error might be because of the com.google.android.gms.maps.MapFragment package in the main.xml . i have com.google.android.gms package in my DUT but not able to find com.google.android.gms.maps.MapFragment. How can i know whether this package is in my DUT or not and also what is the solution to the error.
推荐答案
MapFragment
是一部分的的Google Play服务
库。要使用它,你需要导入的Google Play服务
到工作
,然后从你的项目中引用它,你可以芦苇它是如何在这篇博客我写的前3步
完成的:
MapFragment
is part of the google-play-services
library. To use it you need to import the google-play-services
into your workspace
and then reference it from your project, you can reed how it's done in the first 3 steps
of this blog post I wrote:
这篇关于要通过使用谷歌地图API的Android V2创建Android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!