为什么我在HTC上错过了Google Play服务的错误?

时间:2014-01-02 07:06:36

标签: android google-play-services

我从官方Android网站下载了Geodetection示例应用程序(Geofencing的示例应用程序):http://developer.android.com/training/location/geofencing.html

我的HTC有Android操作系统版本2.3.5。

这是我的清单文件:

<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2013 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

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

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

    <!--
        Requests address-level location access, which is usually
        necessary for geofencing
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<meta-data android:name="com.google.android.gms.version" />
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:allowBackup="true" >

        <!-- The app's entry point -->
        <activity
            android:name="com.example.android.geofence.MainActivity"
            android:label="@string/title_activity_geofence" >
            <intent-filter>
                <!--
                    This activity is triggered when the system
                    tries to start the app's main activity
                -->
                <action android:name="android.intent.action.MAIN" />

                <!--
                    This activity should be linked to the app's Launcher icon
                 -->
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name="com.example.android.geofence.ReceiveTransitionsIntentService" android:exported="false"></service>
    </application>

</manifest>

以下是我在尝试导入Google Play服务时所获得的内容......一个灰色的复选框:

enter image description here 应用程序也可以在仿真器和HTC设备上成功加载。当我点击“注册地理围栏”按钮时,会抛出运行时错误。

enter image description here 找不到Google Play服务资源。检查项目配置以确保包含资源。

不知何故,我已成功添加Google Play服务作为参考。这是截图: enter image description here

这是我的日志猫: enter image description here

这是什么问题?以及如何解决它?

2 个答案:

答案 0 :(得分:2)

您是否在工作区中导入google-play-services_lib了?并将其作为项目中的库包含在内?
编辑:
如何导入

打开Android ADT。文件&gt;导入&gt; Andriod&gt;导入现有的android项目&gt;
从/ sdk / extras / google / google-play-services_lib导入google-play-services_lib


导入该项目后,如果您获得任何错误,请解决错误。
然后是 右键单击您的项目&gt;属性&gt; Android&gt;在“库”选项卡下&gt;从工作区添加并选择项目。

答案 1 :(得分:1)

将Google Play服务版本添加到您应用的清单

  

编辑应用程序的AndroidManifest.xml文件,然后添加   在元素中声明如下。这嵌入   该应用程序编译的Google Play服务版本。

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