这个应用程序需要更新Google Play服务(通过Bazaar),否则无法运行。

102

我正在测试新的Google Maps API V2 for Android,当应用程序启动时出现以下消息:

MainActivity showing error message

这是在一个4.1模拟器上运行。

这是我的AndroidManifest.xml文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.maptest"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <permission
        android:name="com.example.maptest.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>
    <uses-permission android:name="com.example.maptest.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <!-- Require OpenGL ES version 2 -->
    <uses-feature
          android:glEsVersion="0x00020000"
          android:required="true"/>

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

        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="##myapikey##"/>

    </application>
</manifest>

文件 MainActivity.java:

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}

文件 activity_main.xml 的操作

<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" >

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

点击“更新”会导致应用程序崩溃并显示以下堆栈跟踪:

E/Trace(1034): error opening trace file: No such file or directory (2)
W/GooglePlayServicesUtil(1034): Google Play services out of date.  Requires 2010100 but found 1
W/GooglePlayServicesUtil(1034): Google Play services out of date.  Requires 2010100 but found 1
W/GooglePlayServicesUtil(1034): Google Play services out of date.  Requires 2010100 but found 1
W/GooglePlayServicesUtil(1034): Google Play services out of date.  Requires 2010100 but found 1
W/GooglePlayServicesUtil(1034): Google Play services out of date.  Requires 2010100 but found 1
W/GooglePlayServicesUtil(1034): Google Play services out of date.  Requires 2010100 but found 1
D/gralloc_goldfish(1034): Emulator without GPU emulation detected.
D/AndroidRuntime(1034): Shutting down VM
W/dalvikvm(1034): threadid=1: thread exiting with uncaught exception (group=0x40a13300)

E/AndroidRuntime(1034): FATAL EXCEPTION: main
E/AndroidRuntime(1034): android.content.ActivityNotFoundException: No Activity found to handle Intent
  { act=android.intent.action.VIEW dat=http://play.google.com/store/apps/details? \
  id=com.google.android.apps.bazaar flg=0x80000 pkg=com.android.vending }
E/AndroidRuntime(1034):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
E/AndroidRuntime(1034):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
E/AndroidRuntime(1034):     at android.app.Activity.startActivityForResult(Activity.java:3351)
E/AndroidRuntime(1034):     at android.app.Activity.startActivityForResult(Activity.java:3312)
E/AndroidRuntime(1034):     at android.app.Activity.startActivity(Activity.java:3522)
E/AndroidRuntime(1034):     at android.app.Activity.startActivity(Activity.java:3490)
E/AndroidRuntime(1034):     at com.google.android.gms.internal.c$2.onClick(Unknown Source)
E/AndroidRuntime(1034):     at android.view.View.performClick(View.java:4084)
E/AndroidRuntime(1034):     at android.view.View$PerformClick.run(View.java:16966)
E/AndroidRuntime(1034):     at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime(1034):     at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(1034):     at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(1034):     at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime(1034):     at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(1034):     at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(1034):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime(1034):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime(1034):     at dalvik.system.NativeStart.main(Native Method)

我还参考了Google Play服务项目。我做错了什么?

更新

在Google问题跟踪器中相应的bug (https://issuetracker.google.com/issues/35822258) 一段时间前已经被解决。

现在,您可以像这个答案中所述那样,在模拟器中使用Google Maps Android API并创建具有Play服务的虚拟设备:

https://dev59.com/YWUq5IYBdhLWcg3wY_ga#46246782


你是使用带有Google API的AVD还是纯Android? - Selvin
纯Android,虽然我刚尝试切换到4.1的Google API,但是情况一样。 - soren.qvist
包含的示例MapDemo怎么样?它对你来说可以吗?我的在同一模拟器上崩溃并出现ExceptionInInitializationError。 - soren.qvist
2
提出 - http://code.google.com/p/gmaps-api-issues/issues/detail?id=4627 - gazreese
显示剩余9条评论
12个回答

0

从Android SDK Manager中安装: 附加组件:Google Play服务


0
 just change it to 

compile 'com.google.android.gms:play-services-maps:9.6.0'
compile 'com.google.android.gms:play-services-location:9.6.0'

这对我有效,当前版本是10.0.1


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接