This app won't run unless you update Google Play Services

故事扮演 提交于 2019-12-06 07:38:06

问题


I've been trying constantly now to get google maps for android V2 to work. I'm trying this on device : Samsung Galaxy S [2.3.3] and on emulators.

My manifest: (I've tried using both Debug key and Release key)

        <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.klottr"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <permission 
        android:name="com.example.klottr.permission.MAPS_RECEIVE" 
        android:protectionLevel="signature"></permission>
    <uses-permission 
        android:name="com.example.klottr.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"/>

    <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" >
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyDqmCXjO-h-Yy_qGsyVrUz_icB9mCTUzLM"/>
        <activity
            android:name="com.example.klottr.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>

</manifest>

The mainactivity 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"
          tools:context=".MainActivity" >

         <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />
    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment"/>

</RelativeLayout>

The mainactivity java file:

package com.example.klottr;

import com.example.klottr.R;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class MainActivity extends FragmentActivity {
    GoogleMap googleMap;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);
 }

}

I've tried following the guide on the google website, and several guides and tricks from stackoverflow. I'd more than appreciate some tips. I'm just trying to get my device to show the map correctly at the moment, but instead I get "This app won't run unless you update Google Play Services" , Even though the latest version of Google Play Services is installed on my device.


回答1:


Google updated google_play_service library, but not the Play Services app in the google play. So I suggest you to download "Google play services for Froyo" in the Android SDK Manager and plug it to the project instead of the current one.




回答2:


Possible issue 1: READ_GSERVICES not present in manifest

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

Link: http://t1685.codeinpro.us/q/51502052e8432c04261af736

Possible issue 2: This may just be the namespace of my app but in comparison it may be something to consider

<permission android:name="com.fooapp.**androidmapsv2**.permission.MAPS_RECEIVE" android:protectionLevel="signature"></permission>
<uses-permission android:name="com.fooapp.**androidmapsv2**.permission.MAPS_RECEIVE" />



回答3:


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



回答4:


I just got it working on my laptop. The issue on my laptop was however only authorization failure. Seems like my eclipse on the other pc was bugged or something. The code in the working project is almost exactly the same, with these exceptions:

In the manifest, these lines exist in the working project:

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

In MainActivity.java:

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

    /*Test*/
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

And the only thing in my layout xml:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.SupportMapFragment"/>

Still have no idea why it didn't work from my previous code. Note: Map is still blank on emulator, but works fine on Samsung Galaxy S 2.3.3 device



来源:https://stackoverflow.com/questions/18880836/this-app-wont-run-unless-you-update-google-play-services

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