Error while fetching Advertising ID : IllegalStateException

923 views
Skip to first unread message

Udayan

unread,
Nov 20, 2013, 2:31:20 AM11/20/13
to google-adm...@googlegroups.com
Hi,

Facing following strange error while fetching Advertising ID on Android Devices. 

java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 but found 4033500.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

  1. I have added " <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />" in manifest at right place
  2. Have added/linked google_play_services_lib project 
  3. The code is working perfectly fine on Android Emulator (Running Google API 19). But it is not working on devices.
  4. I have tested on Nexus 4 (Running 4.3) and Samsung S3 (4.1.3). Both devices have Google play services installed. And I can see the Advertising ID in "Google_Settings -> Ads". 
  5. isGooglePlayServicesAvailable method returns status 0. i.e. success. On both devices and emulator. 
Am I missing out anything here? Any help is greatly appreciated.

--
Thanks,
UD 

Eric Leichtenschlag

unread,
Nov 21, 2013, 9:39:47 PM11/21/13
to google-adm...@googlegroups.com
Hi Udayan,

Check the res/values/version.xml file in your google play services library project. Is it 4033500? The latest Google Play services version should be 4030500.

Thanks,
Eric

Udayan

unread,
Nov 21, 2013, 11:16:09 PM11/21/13
to google-adm...@googlegroups.com
Hi Eric,

Thanks for the response!

I have checked the res/values/version.xml file in GPS library project. Is it correct 4030500.
Also note that I do have latest GPS lib project downloaded.
I searched the workspace for the value 4033500 but couldn't find it.

As I mentioned earlier, the same code is working perfectly fine on emulator. But on devices somehow it shows the ver 4033500.

It appears to be a forward compatibility issue to me. That the Google play services (google settings app) installed on device is newer than the gps library with which the code is compiled.

Thanks,
UD

Udayan

unread,
Nov 22, 2013, 2:36:31 AM11/22/13
to google-adm...@googlegroups.com
Hi Eric,

Correction in the previous post...

I have checked the res/values/version.xml file in GPS library project. It is correct 4030500.

--
Thanks,
UD

Eric Leichtenschlag

unread,
Nov 22, 2013, 5:14:35 PM11/22/13
to google-adm...@googlegroups.com
Hi Udayan,

I've tested using a more recent version of GPS library installed on the device, but older version referenced from a project, and it still works fine as long as the version in your manifest is the same as the version in the library project you're compiling against.

Let's define these three variables:
A = the version you specify in your manifest
B = the version specified in res/values/version.xml of the library project you're referencing
C = the version of Google Play services installed on the device.

The error here is happening because it expected your manifest to have version B but found version A. This particular error doesn't depend on version C.

I don't know how your app's manifest picked up version 4033500 since you're referencing the library's resource. Did you by any chance define a google_play_services_version resource in your own app?

This issue could possibly be solved by hardcoding the meta-tag value to 4030500 instead of @integer/google_play_services_version, but that's not a long term solution because it'll be out of sync again the next time you update the GPS library you're referencing. In theory, referencing @integer/google_play_services_version should always pull the value from the library project, so A and B would by definition always be in sync.

Thanks,
Eric

Udayan

unread,
Nov 25, 2013, 5:21:53 AM11/25/13
to google-adm...@googlegroups.com
Hi Eric,

Sorry for a late reply.

As mentioned,

1. A = the version you specify in your manifest: (Inside application tag)
<meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

2. B = the version specified in res/values/version.xml of the library project you're referencing
<integer name="google_play_services_version">4030500</integer>

3. C = the version of Google Play services installed on the device.
(Not sure about this)

One more observation: 
The logs show one error as: 
E/GooglePlayServicesUtil(8359): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

As you said, I also hardcoded the meta-tag to 4030500. But strangely, the logcat shows same error. And the code fetches 4033500. 
I can confirm that I have not defined "google_play_services_version" anywhere in project. (Also did a string search in the whole workspace)


Update: 
The code now fetches new version value as 4034500. It seems that GPS app on my device is updated. But the error log stays the same (version updated):
W/System.err(4900): java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 but found 4034500.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

From the above log one thing is sure that version is getting fetched from the device and not from the code. 


I will again emphasize on the fact that, this same code is working fine on Android Emulators (Running Google API).  

--
Thanks,
UD

Eric Leichtenschlag

unread,
Nov 26, 2013, 1:55:59 PM11/26/13
to google-adm...@googlegroups.com
Hey Udayan,

For C, you can get this version by checking The Google Play services app info in settings. You'll see that you probably have version 4.0.34, which was recently rolled out. All the evidence from your side does suggest that it's pulling that version from the device. But I'm not able to reproduce this behavior.

Can you try logging the Google Play Services version code in your app:

Log.w("TEST", "Play Services Version id: " + GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE);

I'd expect to see this be the value of B, or 4030500 in your case.

Assuming you don't get the expected value, could you provide what device you're trying this on, and zips of your Google Play services library project and basic app that reproduce the issue?

Thanks,
Eric
Reply all
Reply to author
Forward
0 new messages