【问题标题】:This app won't run unless you update Google Play Services除非您更新 Google Play 服务,否则此应用将无法运行
【发布时间】:2013-09-23 17:17:51
【问题描述】:

我现在一直在努力让 google maps for android V2 工作。 我正在设备上尝试这个:Samsung Galaxy S [2.3.3] 和模拟器。

我的清单: (我尝试过同时使用 Debug 键和 Release 键)

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

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>

mainactivity java 文件:

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);
 }

}

我已尝试按照 google 网站上的指南以及 stackoverflow 中的一些指南和技巧进行操作。我非常感谢一些提示。 我现在只是想让我的设备正确显示地图,但我得到了 “除非您更新 Google Play 服务,否则此应用将无法运行”,即使我的设备上安装了最新版本的 Google Play 服务。

【问题讨论】:

  • 您如何将 google play 服务库链接到项目中?
  • 将现有的android代码导入工作区(/extras/google/google_play_services/libproject/google-play-services_lib)右键项目->属性->安卓->添加->选择google play服务库
  • 您是否还看到了 Android Private Libraries 和 Android Dependencies 下的 google play jar?我问是因为我基本上有同样的问题,我看到了。不确定这是否正确,但似乎没有任何办法没有它。另外,你是在导入的时候把项目复制到工作区吗?
  • 将项目复制到工作区:是实际上在 Android 私有库中:google-play-services.jar(位于 ../google-play-services_lib/libs 在 Android 依赖项中:google-play-services_lib.jar (位于 ../google-play-services_lib/bin
  • 订购和出口标签怎么样?而且,需要明确的是,您没有看到 Adnroid Dependencies 下的 jar,只是 Android Private Libraries,对吗?等等,没关系,只是重读你的评论,呃。对不起

标签: java android eclipse google-maps google-maps-api-2


【解决方案1】:

Google 更新了 google_play_service 库,但没有更新 google play 中的 Play Services 应用。 所以我建议你在 Android SDK Manager 中下载“Google play services for Froyo”,并将其插入项目而不是当前的项目。

【讨论】:

    【解决方案2】:

    我刚刚让它在我的笔记本电脑上运行。然而,我笔记本电脑上的问题只是授权失败。好像我在另一台电脑上的日食被窃听了。 工作项目中的代码几乎完全相同,但有以下例外:

    在清单中,这些行存在于工作项目中:

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

    在 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;
    }
    

    我的布局 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"/>
    

    仍然不知道为什么它在我之前的代码中不起作用。 注意:地图在模拟器上仍然是空白的,但在三星 Galaxy S 2.3.3 设备上可以正常工作

    【讨论】:

      【解决方案3】:
      <uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="17" />
      

      【讨论】:

        【解决方案4】:

        可能的问题 1:清单中不存在 READ_GSERVICES

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

        链接:http://t1685.codeinpro.us/q/51502052e8432c04261af736

        可能的问题 2:这可能只是我的应用程序的命名空间,但相比之下它可能需要考虑

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

        【讨论】:

        • 我的都有。我应该指出,在 sdk 管理器最近更新到 22.2 之前,我的项目运行良好。从那以后,这一切都归于他的双曲棍球棒;-)
        • 嗯。我没有看到 GS 服务许可。我的错。
        • 哦,完全不用担心;非常感谢您的回复。非常感谢任何对解决方案的尝试。
        • 我刚刚用我的笔记本电脑让它工作了。在我的笔记本电脑上,它之前显示了一个带有按钮的空地图,无法访问谷歌服务,似乎 eclipse 在我手动构建项目之前没有更新 apikey/fingerprint 的正确路径。我仍然不知道为什么它不适用于我上面的代码
        • 抱歉,我无法为您的实际解决方案添加评论(缺少代表),但如果模拟器没有将“Google APIs - API #”设置为目标,而不仅仅是“API #”这可能会导致该问题。
        猜你喜欢
        • 1970-01-01
        • 2013-10-21
        • 2014-06-20
        • 1970-01-01
        • 2012-11-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多