ChatGPT解决这个技术问题 Extra ChatGPT

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

I have an application that uses the Google Maps Android v2 API. I've added the google-play-services_lib library project to my workspace and added a reference to it from my application project, following the instructions on these pages:

http://developer.android.com/google/play-services/setup.html.

https://developers.google.com/maps/documentation/android/start

Everything seems to work fine: The app displays maps and overlays with the default markers. So I'm pretty sure I've got the Google Play services and Google Maps API stuff set up correctly.

However, I see this message in the ADT LogCat window whenever the map view is initialized (on a 2nd-gen Nexus 7):

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

The message level is Error, and the tag is GooglePlayServicesUtil.

This seems benign, as my app does work fine. But what can I do or check to try to address whatever the problem might be?

Further info: Each time the "Google Play services resources were not found" message appears in LogCat, it is preceded by these messages, which are Warnings and tagged 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, I can't find the constant 0x7f0b038a anywhere when I search the projects, including the gen/R.java files.

I've checked the contents of the generated .apk, and it includes all of the resources that are in the google-play-services_lib/res directory.

Another update: After adding ActionBarSherlock and updating the targetSdkVersion in my manifest from 8 to 17, I now see another error in the LogCat output:

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

More details about that problem can be found here: Google Maps works fine on Android but I still get an error "Could not find class 'maps.i.k', referenced from method maps.z.ag.a"

And once again, the app seems to work just fine. Maybe it's safe to ignore these "errors"?

Happening the same here, using Gradle + Android Studio! 08-06 19:47:00.376 2141-2141/com.menor.android.assignment.tempos21 E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
Try cleaning all of the projects in your workspace (under Project > Clean). I've noticed that this sometimes fixes R.java/resource issues.
Same thing is happening here, clean didn't help. I think it started after I updated stuff in the android sdk manager
Same thing here (Eclipse as well), it most likely is because of the latest SDK update (22.0.5). Today Google Play Services was updated to rev10, but I still have the error message. What's even worse; my Google Maps Fragment has stopped working It doesn't want to display any map, only an endless blue canvas.
Goggle says "You can safely ignore this message. Your app will still fetch and serve banner ads."

e
elliptic1

Google Mobile Ads SDK FAQ states that:

I keep getting the error 'The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.' You can safely ignore this message. Your app will still fetch and serve banner ads.

So if you included the google-play-services_lib correctly, and you're getting ads, you have nothing to worry about (I guess...)


maybe you can ignore, but I keep getting into a code that doesn't exist, each time I choose to debug the app.
What if I'm not using ads? Would Google Play Services still be trying to do whatever it is that generates the message?
I see this also in a different app where I just register for GCM push notifications, and everything seems to be working fine.
when i run app in android emulator injected ads is displaying, but if i run same app into physical android device then it is displaying blank screen
This is my experience and opinion Also
K
Kristopher Johnson

This is a bug in the Google Play services library, and it is filed here under issue 755.

Unfortunately, there isn't any solution yet.


This post dates back to 2014, I am getting this error right now, is this post relevant?
@sachithkn weird enough, I had problems in my code, on inspection and debugging I found that out. Instead of showing error in my code it crashed at API level, probably I did some bad code by adding try-catch somewhere which forcefully ran the code, eventually crashing at API call (or in API). So I fixed my code and error is gone. At least this is what I think happened.
P
Peter Mortensen

I just ran into this problem this morning and seemed very strange since my application was working fine up until today. I was getting the exact same "The Google Play services resources were not found..." message.

I tried opening the regular Google Maps application to see if I could get my location, but it wouldn't find it. Even after waiting 5 minutes, which is more than enough time to normally get a location from even the service provider via cell tower. So I checked Location Services.

Anyway, the problem turned out to be that on my S3 under Location Services -> Google Location Services. It was not checked. The other two location options were checked (VZW Location Services and Standalone GPS Services), but the last one, Google Location Services was not. After turning that on, the regular Google Maps could find my location and my application could find my location and the problem went away.

The error message pops up due to:

mMap.setMyLocationEnabled(true);

when Google Location Services is not enabled.

After doing some more testing it looks like if the current location is null (cannot be determined from all sources) then you will get this error when trying to turn on setMyLocationEnabled.


This is the root of the issue from what I can tell as well. If you remove the call for setMyLocationEnabled(), you will no longer get the error. Even though its listed as an error, it seems to be harmless as the app continues to perform fine and the functionality to display my location in the application continues to work fine as well. Not sure why its coming up as an error.
setMyLocationEnabled has nothing to do with this, since on all of my devices Location Services are enabled in settings. I suspect the latest google-play-services.jar is broken.
My problem had a almost similar fix i needed to switch my location on in Android 4.4 you actually see the app which is requesting location, and my app was one of those. I guess its to do with setOnMyLocationChangeListener rather than setMyLocationEnabled which gives that error. There needs to be check of some kind before you can request location and check if location services are on. Should help
P
Peter Mortensen

I have decompiled Google Play services revision 14 library. I think there is a bug in com.google.android.gms.common.GooglePlayServicesUtil.class. The aforementioned string appears only in one place:

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

There is no R.class in com.google.android.gms.common package.

There is an import com.google.android.gms.R.string;, but no usage of string.something, so I guess this is the error - there should be import com.google.android.gms.R;.

Nevertheless the isGooglePlayServicesAvailable method works as intended (except of logging that warning), but there are other methods in that class, which uses unimported R.class, so there may be some other errors. Although banners in my application works fine...


P
Peter Mortensen

You have to add the google-play-services-lib as a library-project. They updated the SDK. There are several tutorials around. For Eclipse it is easy:

Right click project -> properties -> Android

https://i.stack.imgur.com/JDv0L.jpg

For more detailed walkthroughs:

Importing the library-project

How to get GoogleMaps running on emulator


As stated in the question, I have added the google-play-services_lib library project, and everything is working fine.
ok, you didn't explictly said that you use the google-play-services-lib as a PROJECT, so i tried to point it out. i will re-think the problem.
FWIW, I've looked at the generated .apk, and it does contain all the resources from the google-play-services_lib project, so I'm pretty sure the library project is added and referenced correctly.
Do you know how to do the equivalent operation in Android Studio? I do not wish to import it with maven
m
mDroidd

I had this issue too. The way I solved it was the following:

Delete the google-play-services_lib library-project. Remove the (now invalid) google-play-services_lib reference in [your project] > Properties > Android. Imported the google-play-services_lib library-project from android-sdk-x/extras/google_play_services/libproject. When you import a project, you get the option "Copy project into workspace". UNCHECK IT. Add the (now valid) google-play-services_lib reference to your project with [your project] > Properties > Android.

This did the trick for me. I hope it helps you too!


Just an FYI you shouldn't import google play services directly from the SDK. You should keep the "Copy project into workspace" box CHECKED if you do, or copy the directory into your workspace, or better yet into your version control system. Ran into this issue today where some devs were using an older version and some were using the latest and the project code was failing with the latest because it didn't have the newly required google maps meta data in the Manifest.
Do you know how to do the equivalent operation in Android Studio? I do not wish to import it with maven
P
Peter Mortensen

I am encounted this problem when I am using Admob JUST because I forgot to write my Ad Unit ID into @string.


Where did you say you forgot to do that? I'm creating my adview programmatically, and passing such id programmatically too.
k
kopi32

I had the same issue. In the Google APIs Console, you should check that there is only one key generated for that app. I had a stretch where I migrated my code from one PC to the next and so on (it got messy), and had multiple keys for my one project. The older keys are all listed as inactive on the API console page, but for some reason caused a conflict. After deleting them completely, I ran it again and it worked.


P
Peter Mortensen

As for me I've solved this problem by next way - as developer.android.com says, after adding google-play-services_lib you should add <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> in your manifest, but on the new SDK you'll always get an error:

Error: No resource found that matches the given name (at 'value' with value '@integer/ google_play_services_version').

To solve that error many people advise to use a raw value, 4030500, instead of @integer/google_play_services_version, but it is correct ONLY for Google services revision 13.

If you use any older version or version for Froyo (like me) you should put another value in it. To know what value you should put just open a Google Play services manifest and copy-paste a version_code value. For Froyo services, it is 3265130. After adding this I've stopped getting this error, and I've began to receive coordinates in my application at last.


4030500 gave me an error. However the correct value to use was provided in the logcat.
@Maverick what is your google_play_services version? Check it in android sdk manager
P
Peter Mortensen

For me the only working solution was to add the android-support-v7-appcompat library as well. It seems that this library is also needed in order to get rid of that message. Since then my applications have been working fine!

I hope it helps!


This did not work for me what sdk did you compile your project for?
P
Peter Mortensen

I had the same issue here. As Magnus said above, for me it was happening due to an SDK update to version 22.0.5.

After performing a full update in my Android SDK (including Google Play Services) and Android plugins in Eclipse, I was able to use play services lib in my application.


C
Community

For IntelliJ IDEA users

After struggling for a couple of days, the only way to make it work in IntelliJ IDEA 13 was to import the library. Here are all the steps:

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.

On the link I provided below, you can see an image of how it looks in my IntelliJ IDEA 13. It would not work without adding only one of these two.

PS. I asked a question, Why does IntelliJ IDEA 13 require both lib project and lib itself (google-play-service) to be added as a dependency?, why is it a must in IntelliJ IDEA 13, and why we cannot import either the library or project only.


Could you list the exact manipulations you are doing to import the google-play-services_lib project as a module dependency (I use Android Studio 0.3.6)
@RaphaelRoyer-Rivard Done! Note that these steps are for IDEA 13, not for Android Studio so some steps may differ, thou it should be the same.
Actually, it's the operation 4 and 5 that causes me problems. I open the Project Structure with F4, then I go to Modules, click on the + and there is a popup window named New Module. Do I references the google-play-services_lib folder from here (in the Content root field)?
@RaphaelRoyer-Rivard Just direct to the folder not JAR library. And add the whole project as a module. Is this what you asked?
Well, it isn't simple as selecting a folder in my case. I must choose the Module type from this list (Java, Maven, Gradle, JavaFX Application, Command Line App, Groovy, Griffon, Gradle: Android Module, Gradle: Android Project, Gradle: Java Library). And then selecting a folder in the field Content root. Is Java the right Module type to choose?
P
Peter Mortensen

I also had the same problem. In starting, it was working fine then, but sometime later I uninstalled my application completely from my device (I was running it on my mobile) and ran it again, and it shows me the same error.

I had all lib and resources included as it was working, but still I was getting this error so I removed all references and lib from my project build, updated google service play to revision 10, uninstalled application completely from the device and then again added all resources and libs and ran it and it started working again.

One thing to note here is while running I am still seeing this error message in my LogCat, but on my device it is working fine now.


P
Peter Mortensen

I also had the same issue. I also tried to look for solutions, but after I didn't find any of the solutions working, I tried to restart my mobile (Android device), and it resolved the issue.

Please give it a try! Restart your mobile device and Eclipse to be on safe side and check if it works.


S
Syed

I had the same issue i have created own API to check whether google play service is installed or not , it works fine for me. Just pass package information of google play service it will give you the value

below is the code:

        LOG.d(LOG_IDENTIFIER, "info  : "+ info);

        return true;
    }
    catch(PackageManager.NameNotFoundException e)
    {
      e.printStackTrace();

        LOG.e(LOG_IDENTIFIER, "NameNotFoundException  : "+ e.getMessage());
    }


    return  false;
}


S
Seïfane Idouchach

For me deleting the following code fixed it !

mLocationClient.setMockMode(true);

a
async

LE: I just remembered this was about using Google Maps, so my answer doesn't really answer the initial question, but I hope some people will save hours/days banging their heads on their desks if they have the same issue with Play Game Services.

I too had this incredibly cryptic error. It wasn't anything related to location services for me, but with not properly reading the documentation, more precisely step 3, where it says to add the following to your AndroidManifest.xml:

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

You should obviously also have the following in AndroidManifest.xml

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

I was using the BaseGameActivity they suggest to use when you want to implement game services so I was a bit surprised it didn't work straight away. I did create a dedicated module for a copy of the google-play-services_lib, I did have the latest version of it (4323000 as of writing) and I did set this as a module dependency to my main module (using Android Studio here). But that little line above fixed everything.


a
aprados

I had the same problem. As Kristopher Johnson said, I referenced google-play-services_lib, but it didn't work. I added google_play_services_lib.jar (look at your SDK/google folder) under project properties/java build path/libraries/android dependencies and error vanished.


P
Peter Mortensen

I had the exact same problem when working with several developers. If I RUN the project from my ADT it works well, but from theirs it isn't..

The answer was to put their SHA-1 key with the package name in Google API console as well as mine. We are three developers, so we needed to put in three SHA-1 keys..

I hope it gives you some inspiration...


P
Peter Mortensen

In my case it meant, there is some kind of mistake in my implementation, and it says that it cannot find the resource for the error message to be properly shown in LogCat. When I fixed that mistake in my implementation the problem from LogCat was gone as well. So actually unless you are missing some really neccessary resource you should not concentrate to fix the missing resources, but rather fix your implementation.

The mistake, BTW, was that I was running ads in debug mode without going to ads test mode.


C
Community

I believe that this is a bug in the current Google Play Services library, revision 15, as the underlying cause appears to be caused by failing to read a resource file:

W/ResourceType(25122): Requesting resource 0x7f0c000d failed because it is complex E/GooglePlayServicesUtil(25122): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

It seems that the Google Play Services library attempts to read a resource file and has a generic catch-all that displays this error message when the resource fails to load. This corresponds with what kreker managed to decompile from the library and would explain the log messages.


佚名

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