Google Play Services Library update and missing sy

2019-01-01 12:28发布

When upgrading my project to the latest version of Google Play Services (v4.0, released on Halloween 2013), you are now supposed to add a new tag into the AndroidManifest.xml file.

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

Unfortunately, when I try doing that, I then get this compile error:

android-apt-compiler: /blahblah/AndroidManifest.xml:409: error: Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').

I can then navigate to the file at google-play-services_lib/res/values/version.xml and view the raw integer for that symbol:

<integer name="google_play_services_version">4030500</integer>

And then insert it back into my AndroidManifest.xml:

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

Doing this works absolutely fine and I can then compile and run the project and app just fine. But it's definitely an undesirable fix with obvious upgradability issues.

Any ideas?

24条回答
皆成旧梦
2楼-- · 2019-01-01 12:57

Please note that this fix may only apply to IntelliJ users!! (More information at the bottom of this post that should apply to everyone.)

Fixed this problem! I use IntelliJ and it turns out I just had misconfigured the way I was including the google-play-services_lib module as a dependency.

As I fixed this entirely through GUI and not at all by editing any files, here's a couple of screenshots:

Step 1 - Initial Project Structure So my Project Structure started off looking like this...

Step 2 - Removed google-play-services library Then I removed the google-play-services library from my dependencies list by selecting it and then clicking the minus button at the bottom. Notice the error at the bottom of the dialog, as my project absolutely does require this library. But don't worry, we'll re-add it soon!

Step 3 - Added google-play-services as a module dependency Next I added google-play-services_lib as a module dependency instead of a library dependency. Then I hit the up arrow button at the bottom a couple times to move this dependency to the top of the list. But notice the error at the bottom (we're still not done yet!)

Step 4 - Click the lightbulb to add the google-play-services library as a dependency I then clicked the lightbulb at the bottom of the dialog in the error message area to bring up this little small popup that gives two choices (Add to dependencies... or Remove Library). Click the Add to dependencies... option!

Step 5 - Add the library to the google-play-services_lib module A new small dialog window should have popped up. It gave me two choices, one for my main project (it's name is blurred out), and then another for the google-play-services_lib project. Yours may have a bunch more depending on your project (like you may see actionbarsherlock, stuff like that). Select google-play-services_lib and click okay!

And finally, you're done! I hope this helps someone else out there!

Further info

I believe the reason that this issue was happening to begin with is because I thought that I had properly included the entire google-play-services_lib project into my overall project... but I actually had not, and had instead only properly included its jar file (google-play-services_lib/libs/google-play-services.jar). That jar file only includes code, not Android resources values, and so as such the @integer/google_play_services_version value was never really in my project. But the code was able to be used in my project, and so that made it seem like everything was fine.

And as a side note, fixing this issue also seems to have fixed the GooglePlayServicesUtil.getErrorDialog(...).show() crash that I used to have. But that could also have been fixed by the update, not really 100% sure there.

查看更多
泪湿衣
3楼-- · 2019-01-01 12:58

I also ran across this while trying to use google_play_services_froyo.

I filed this bug: https://code.google.com/p/google-plus-platform/issues/detail?id=734

查看更多
浅入江南
4楼-- · 2019-01-01 12:58

While importing the google-play-services_lib, check the version code defined in AndroidManifest.xml and version.xml. I had found the difference in version code and change it to 4242000. After making the change there is no more compilation error in @integer/google_play_services_version.enter image description here

查看更多
残风、尘缘若梦
5楼-- · 2019-01-01 13:00

For Eclipse, I just added project reference to the google-play-services_lib in:

Properties-Android In the Library pane (bottom pane), ensure that the google-play-services_lib is listed. If not, click the Add.. button and select google-play-services_lib.

查看更多
姐姐魅力值爆表
6楼-- · 2019-01-01 13:02

On Eclipse, after importing the google play library to the project workspace I just copied the version.xml file from

google-play-services_lib/res/values/version.xml

to

MyProjectName/res/values/version.xml
查看更多
有味是清欢
7楼-- · 2019-01-01 13:03

I faced the same issue, and apparently Eclipse somehow left the version.xml file in /res/values from the original google-play-services_lib project while making a copy. I pulled the file from original project and pasted it in my copy of the project and the problem is fixed.

查看更多
登录 后发表回答