不幸的是,(应用程序名称)已停止当我使用片段使用谷歌地图 [英] Unfortunately, (App Name) has stopped when i use fragment to use Google Maps

查看:439
本文介绍了不幸的是,(应用程序名称)已停止当我使用片段使用谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以澄清在我的错误是什么?有错误的Andr​​oid应用程序崩溃,不幸的是,我的应用程序已停止工作。只是在Main_layout文件把片段时。

Can anyone clarify where my error is? The Android app crashes with the error, "Unfortunately, my app has stopped working".Just when put fragment in Main_layout file.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

    <fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.MapFragment " />
</RelativeLayout>  

和这里是一些manifest文件

And here is some of Manifest file

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

所有权限都存在于我的清单文件,我已经在扩展Java类FragmentActivity

All of the permissions are exist in my Manifest file , and I've extended FragmentActivity in java class

请帮我解决这个问题。

LogCat中:
04-10 23:01:51.963:I / dalvikvm(10356):找不到方法android.content.pm.PackageManager.getPackageInstaller,从方法com.google.android.gms.common.GooglePlayServicesUtil引用.zzg
04-10 23:01:51.963:W / dalvikvm(10356):VFY:无法解析虚方法369:Landroid /内容/ PM /软件包管理系统; .getPackageInstaller()Landroid /内容/ PM / PackageInstaller;
04-10 23:01:51.963:D / dalvikvm(10356):VFY:在0x000b更换运code 0x6e
04-10 23:01:51.963:D / AndroidRuntime(10356):关闭VM
04-10 23:01:51.963:W / dalvikvm(10356):主题ID = 1:螺纹未捕获的异常退出(组= 0x41907d88)
04-10 23:01:51.983:E / AndroidRuntime(10356):致命异常:主要
04-10 23:01:51.983:E / AndroidRuntime(10356):工艺:com.example.myapp,PID:10356
04-10 23:01:51.983:E / AndroidRuntime(10356):了java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.myapp / com.example.myapp.MainActivity}:android.view.InflateException:二进制XML文件行#9:错误充气类片段
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2237)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.app.ActivityThread.access $ 800(ActivityThread.java:144)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1246)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.os.Handler.dispatchMessage(Handler.java:102)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.os.Looper.loop(Looper.java:212)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.app.ActivityThread.main(ActivityThread.java:5135)
04-10 23:01:51.983:E / AndroidRuntime(10356):在java.lang.reflect.Method.invokeNative(本机方法)
04-10 23:01:51.983:E / AndroidRuntime(10356):在java.lang.reflect.Method.invoke(Method.java:515)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:877)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
04-10 23:01:51.983:E / AndroidRuntime(10356):在dalvik.system.NativeStart.main(本机方法)
04-10 23:01:51.983:E / AndroidRuntime(10356):android.view.InflateException:二进制XML文件行#9:错误充气类片段产生的原因
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.view.LayoutInflater.inflate(LayoutInflater.java:492)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.view.LayoutInflater.inflate(LayoutInflater.java:397)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.view.LayoutInflater.inflate(LayoutInflater.java:353)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:297)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.app.Activity.setContentView(Activity.java:1929)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.example.myapp.MainActivity.onCreate(MainActivity.java:23)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.app.Activity.performCreate(Activity.java:5231)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201)
04-10 23:01:51.983:E / AndroidRuntime(10356):... 11个
04-10 23:01:51.983:E / AndroidRuntime(10356):java.lang.IllegalStateException:在应用的Andr​​oidManifest.xml中的元数据标签没有正确的价值所致。预计7095000但发现0。你必须有该元素中的如下声明:
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.google.android.gms.common.GooglePlayServicesUtil.zzJ(来源不明)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(来源不明)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.google.android.gms.maps.internal.zzx.zzad(来源不明)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.google.android.gms.maps.internal.zzx.zzac(来源不明)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.google.android.gms.maps.MapsInitializer.initialize(来源不明)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.google.android.gms.maps.SupportMapFragment $ zzb.zzqs(来源不明)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.google.android.gms.maps.SupportMapFragment $ zzb.zza(来源不明)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.google.android.gms.dynamic.zza.zza(来源不明)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.google.android.gms.dynamic.zza.onInflate(来源不明)
04-10 23:01:51.983:E / AndroidRuntime(10356):在com.google.android.gms.maps.SupportMapFragment.onInflate(来源不明)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
04-10 23:01:51.983:E / AndroidRuntime(10356):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
04-10 23:01:51.983:E / AndroidRuntime(10356):...... 21多
04-10 23:01:54.903:I /流程(10356):发送信号。 PID:10356 SIG:9

这是清单文件

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="18" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <!-- You must insert your own Google Maps for Android API v2 key in here. -->
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyA--------------------ZQjV4U" />

    <meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

    <activity
        android:name="com.example.myapp.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

推荐答案

看起来像一个错误就在于你的清单 - 产生的原因:java.lang.IllegalStateException:在应用的Andr​​oidManifest元数据标签的.xml没有正确的价值。预计7095000但发现0

Looks like an error lies in your manifest - Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 7095000 but found 0

我看不到你的清单文件的内容,但我的第一个猜测是,你没有设置谷歌Play服务的版本或谷歌地图API密钥的元数据清单中正常。
一切都在那里解释: https://developers.google.com/maps/documentation/安卓/启动#add_a_map 就像@Daniel纽金特提及。

I cannot see the content of your manifest file, but my first guess is that you didn't set up Google Play services version or google maps api key meta-data in manifest properly. Everything is explained there: https://developers.google.com/maps/documentation/android/start#add_a_map just like @Daniel Nugent mentioned.

这篇关于不幸的是,(应用程序名称)已停止当我使用片段使用谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆