我有一个使用谷歌地图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"

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


当前回答

我已经反编译谷歌播放服务修订版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,因此可能会出现其他一些错误。虽然横幅在我的应用程序工作得很好…

其他回答

我也有同样的问题,我创建了自己的API来检查谷歌播放服务是否安装,它对我来说很好。只要传递谷歌播放服务的包信息,它就会给你值

下面是代码:

公共静态boolean isGooglePlayServicesInstalled() { 试一试 { ApplicationInfo info = NativeActivity.CURRENT.getPackageManager(). getapplicationinfo ("com.google.安卓。Gms ", 0);

LOG.d(LOG_IDENTIFIER, "info : "+ info); return true; } catch(PackageManager.NameNotFoundException e) { e.printStackTrace(); LOG.e(LOG_IDENTIFIER, "NameNotFoundException : "+ e.getMessage()); } return false; }

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

我今天早上遇到了这个问题,看起来很奇怪,因为我的应用程序直到今天都工作得很好。我得到了完全相同的“谷歌播放服务资源未找到…”消息。

我试着打开常规的谷歌地图应用程序,看看是否能找到我的位置,但它找不到。即使在等待5分钟后,这也足够通过手机信号塔从服务提供商那里获得位置了。所以我查了位置服务。

无论如何,问题原来是在我的S3位置服务->谷歌位置服务。它没有被检查。其他两个位置选项被选中(VZW位置服务和独立GPS服务),但最后一个谷歌位置服务没有被选中。打开后,常规的谷歌地图可以找到我的位置,我的应用程序也可以找到我的位置,问题就解决了。

弹出错误消息是由于:

mMap.setMyLocationEnabled(true);

当谷歌Location Services未启用时。

在做了一些更多的测试之后,看起来如果当前位置是空的(不能从所有来源确定),那么你会在尝试打开setMyLocationEnabled时得到这个错误。

我相信这是当前谷歌Play Services库的一个bug,修订版15,因为底层原因似乎是由于未能读取资源文件造成的:

W/ResourceType(25122):请求资源0x7f0c000d失败,因为它很复杂 E/GooglePlayServicesUtil(25122): The谷歌Play services resources were not found。检查您的项目配置,以确保资源包括在内。

谷歌Play Services库似乎试图读取资源文件,并在资源加载失败时显示此错误消息的通用catch-all。这与kreker设法从库反编译的内容相对应,并将解释日志消息。

这是谷歌播放服务库中的一个错误,它在第755号问题下提交。

不幸的是,目前还没有任何解决方案。