【发布时间】:2015-02-25 22:18:52
【问题描述】:
我对 Android 开发非常陌生。我正在使用 Android Studio 1.0.2,并且正在构建一个非常简单的应用程序来显示 Mapview。
我尝试按照几个教程来实现它,但我总是遇到同样的问题。应用程序崩溃并出现以下错误:
12-29 18:47:41.182 3574-3574/com.example.sebastien.myfirstandroidapp D/AndroidRuntime﹕ Shutting down VM
12-29 18:47:41.183 3574-3574/com.example.sebastien.myfirstandroidapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.sebastien.myfirstandroidapp, PID: 3574
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sebastien.myfirstandroidapp/com.example.sebastien.myfirstandroidapp.MapActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
布局仅包含以下内容:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="@+id/mapView"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
我还有一个错误:
Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 6171000 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> at com.google.android.gms.common.GooglePlayServicesUtil.E(Unknown Source) at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
我将非常感谢任何帮助或调查以使这个简单的应用程序运行的想法。
【问题讨论】:
-
您在项目中添加了 google play 服务吗?
-
尝试使用 SupportMapFragment。
-
您的项目中似乎缺少播放服务。
标签: java android google-maps android-studio android-gradle-plugin