我有一个使用谷歌地图Android v2 API的应用程序。我已经添加了google-play-services_lib库项目到我的工作空间,并从我的应用程序项目中添加了对它的引用,按照这些页面上的说明:

http://developer.android.com/google/play-services/setup.html。 https://developers.google.com/maps/documentation/android/start

一切似乎都很正常:应用程序显示地图和覆盖默认标记。所以我很确定我已经正确地设置了谷歌播放服务和谷歌地图API。

然而,我在ADT LogCat窗口中看到这条消息每当地图视图初始化(在第二代Nexus 7上):

The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

消息级别是Error,标记是GooglePlayServicesUtil。

这似乎是良性的,因为我的应用程序运行良好。但是我能做些什么来解决问题呢?


进一步的信息:每次“谷歌播放服务资源未找到”消息出现在LogCat中,它前面是这些消息,这是警告和标记ResourceType:

getEntry failing because entryIndex 906 is beyond type entryCount 3

Failure getting entry for 0x7f0b038a (t=10 e=906) in package 0 (error -2147483647)

FWIW,当我搜索项目时,我找不到常量0x7f0b038a,包括gen/R.java文件。

我检查了生成的.apk的内容,它包括了google-play-services_lib/res目录下的所有资源。


另一个更新:添加ActionBarSherlock和更新targetSdkVersion在我的清单从8到17,我现在看到另一个错误在LogCat输出:

Could not find class 'maps.af.k', referenced from method 'maps.ag.an.a'

关于这个问题的更多细节可以在这里找到:谷歌地图在Android上工作正常,但我仍然得到一个错误“无法找到类的Maps . I。K ',引用自方法maps.z.ag.a"

这款应用似乎又一次运行良好。也许忽略这些“错误”是安全的?


当前回答

至于我,我已经通过下一种方式解决了这个问题-正如developer.android.com所说,在添加google-play-services_lib之后,你应该添加<meta-data android:name="com.google.android.gms.version" android: value = " / google_play_services_version " / > 在你的清单,但在新的SDK,你总是会得到一个错误:

错误:没有找到与给定名称匹配的资源(at 'value'与value' @integer/ google_play_services_version”)。

为了解决这个错误,许多人建议使用原始值4030500,而不是@integer/google_play_services_version,但这只适用于谷歌服务版本13。

如果你使用任何旧版本或版本的Froyo(像我),你应该在它里面放另一个值。要知道你应该放什么值,只需打开谷歌播放服务清单,并复制粘贴一个version_code值。Froyo服务是3265130。添加这个后,我已经停止得到这个错误,我已经开始在我的应用程序中接收坐标。

其他回答

我也有这个问题。我的解决方法如下:

删除google-play-services_lib库项目。 删除[你的项目]>属性> Android中的google-play-services_lib引用(现在无效)。 从android-sdk-x/extras/google_play_services/libproject中导入google-play-services_lib library-project。当您导入一个项目时,您会看到“将项目复制到工作区”选项。取消它。 使用[your project] > Properties > Android添加(现在有效)google-play-services_lib引用到你的项目。

这招对我很管用。我希望它也能帮助到你!

为我删除以下代码修复它!

mLocationClient.setMockMode(true);

我已经反编译谷歌播放服务修订版14库。我认为com.google.android.gms.common.GooglePlayServicesUtil.class有一个bug。前面提到的字符串只出现在一个地方:

public static int isGooglePlayServicesAvailable(Context context) {
    PackageManager localPackageManager = context.getPackageManager();
    try {
        Resources localResources = context.getResources();
        localResources.getString(R.string.common_google_play_services_unknown_issue);
    } catch (Throwable localThrowable1) {
        Log.e("GooglePlayServicesUtil", "The Google Play services resources were not found. "
                + "Check your project configuration to ensure that the resources are included.");
    }
....

在com.google.android.gms.common包中没有R.class。

有一个导入com.google.android.gms.R.string;,但没有使用string。什么,所以我猜这是错误-应该有导入com.google.android.gms.R;。

尽管如此,isGooglePlayServicesAvailable方法仍能正常工作(除了记录该警告),但该类中还有其他方法,它们使用未导入的R.class,因此可能会出现其他一些错误。虽然横幅在我的应用程序工作得很好…

我也有同样的问题。开始时,它工作得很好,但过了一段时间,我从我的设备上完全卸载了我的应用程序(我在我的手机上运行它),然后再次运行它,它显示了同样的错误。

我有所有的库和资源,因为它正在工作,但我仍然得到这个错误,所以我从我的项目构建中删除了所有的引用和库,更新谷歌服务播放到修订10,完全从设备上卸载应用程序,然后再次添加所有的资源和库,并运行它,它又开始工作了。

这里要注意的一件事是,在运行时,我仍然在我的LogCat中看到这个错误消息,但在我的设备上,它现在工作正常。

You know, I don't think it's a bug from sdk. "The Google Play services resources were not found. Check your project configuration to ensure that the resources are included" is exactly right. The jar file putted into your /libs doesn't contain any resources like *xml, *png etc. The error logs mean this. And If your ever added support libraries like v4, v7-appcompat, v7-cardview, v7-recyclerview, v7-pallete or v7-gridlayout, sometimes logs which imply that resources are in short occur. All these is because that resources in projects are not imported. So, import support projects as library ASAP. Of course, you first download this support projects through SDK Manager at the item of extras