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

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


当前回答

对我来说,唯一可行的解决方案是添加android-support-v7-appcompat库。为了消除该消息,似乎还需要这个库。从那时起,我的应用程序一直工作得很好!

我希望这能有所帮助!

其他回答

在我的情况下,它意味着,在我的实现中有某种错误,它说它无法找到资源的错误消息在LogCat中正确显示。当我在我的实现中修正这个错误时,LogCat的问题也消失了。所以实际上,除非你丢失了一些真正必要的资源,否则你不应该专注于修复丢失的资源,而应该修复你的实现。

顺便说一句,错误在于我在调试模式下运行广告而没有进入广告测试模式。

LE:我只记得这是关于使用谷歌地图,所以我的回答并不能真正回答最初的问题,但我希望如果有些人在使用Play Game Services时遇到同样的问题,他们能够省下数小时或数天的时间去敲桌子。

我也犯了这个难以置信的神秘错误。对我来说,这与位置服务无关,但没有正确阅读文档,更准确地说是第3步,它说要将以下内容添加到您的AndroidManifest.xml:

<meta-data android:name="com.google.android.gms.games.APP_ID"
    android:value="@string/app_id" />

显然,在AndroidManifest.xml中还应该有以下内容

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

当你想要实现游戏服务时,我使用了他们建议使用的BaseGameActivity,所以我有点惊讶它不能立即工作。我确实为google-play-services_lib的副本创建了一个专用的模块,我确实有它的最新版本(4323000编写时),我确实将其设置为我的主模块的模块依赖(此处使用Android Studio)。但上面的那句话决定了一切。

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

我也有同样的问题。我也试图寻找解决方案,但在我没有找到任何解决方案后,我试图重新启动我的移动设备(Android设备),它解决了这个问题。

请试一试!为了安全起见,重新启动您的移动设备和Eclipse,并检查它是否正常工作。

适用于IntelliJ IDEA用户

经过几天的努力,让它在IntelliJ IDEA 13中工作的唯一方法是导入库。以下是所有的步骤:

Update Android SDK so the latest Play Service is installed. Go to the android-sdk-root/extras/google/google_play_services/libproject directory. Copy google-play-services_lib and paste it next to your IntelliJ IDEA project (some recommend using this directory directly, but I advise to keep this code clean!). Open IntelliJ IDEA project properties and add new Module google-play-services_lib. Check if it's marked as a Library. Add google-play-services_lib library project as a dependency to the main project. Add google-play-services library as a dependency library as well.

在我下面提供的链接中,你可以看到它在我的IntelliJ IDEA 13中的样子。如果不加上这两个中的一个,它就不能工作。

PS.我问了一个问题,为什么IntelliJ IDEA 13需要库项目和库本身(google-play-service)作为依赖项添加?为什么它在IntelliJ IDEA 13中是必须的,以及为什么我们不能只导入库或项目。