7

I have a plugin for Unity that is written in Java. In this plugin I need to get the new Google Advertisement ID to do it, I have to add to the Manifest file:

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

When I compile, Unity is throwing error:

Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
/Applications/adt/sdk/build-tools/android-4.2.2/aapt package --auto-add-overlay -v -f -m -  J gen -M AndroidManifest.xml -S "res" -I "/Applications/adt/sdk/platforms/android-  19/android.jar" -F bin/resources.ap_

stderr[
AndroidManifest.xml:21: error: Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
]

I also tried to add the Google play services jar to the [lugins/Androif folder but that didn't help. What is the correct way to make it work?

Dima
  • 8,586
  • 4
  • 28
  • 57

4 Answers4

25

To fix this error, you have to copy the version.xml file from android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/res/values/ into Assets/Plugins/Android/res/values/ your Unity project's folder.

jab
  • 4,053
  • 3
  • 33
  • 40
2

Don't copy all project into your Plugins/Android.

  1. Config file Manifest.xml to right information. Copy to Plugins/Android.

     <meta-data android:name="com.google.android.gms.games.APP_ID"
                  android:value="\ android app id " /> 
              <meta-data android:name="com.google.android.gms.appstate.APP_ID"
                      android:value="\ android app id " /> 
              <meta-data android:name="com.google.android.gms.version" 
                  android:value="@integer/google_play_services_version" /> 
              <activity android:name="com.google.example.games.pluginsupport.SignInHelperActivity"
     />
    
  2. Copy Google play services jar -> to Plugins/Android

  3. Copy all res folder -> to Plugins/Android/res

Frank Nguyen
  • 6,493
  • 3
  • 38
  • 37
  • Can you explain if I need to set the "\ android app id " to something or leave as is? – Almog C Aug 07 '14 at 13:27
  • I tried the above and it didn't work. I copied the snippet as-is to the Application node in the Manifest.xml. Any idea what I'm missing? – Almog C Aug 07 '14 at 14:52
  • Android App ID is a string you can get from Google Developer Console. Go to here https://developers.google.com/games/services/console/enabling -> Set up your game -> Create Client IDs – Frank Nguyen Aug 08 '14 at 06:36
1

An updated simple solution:

Today, i have same issue. I noticed that, when i copy folder from android-sdk/extras/google/google_play_services/libproject/ named google-play-services_lib ; there is already this folder in Assets/Plugins/Android on unity. And name of the copied folder is to be goole-play-services_lib 1.

So i only deleted this folder, and it is working fine.

TFA
  • 59
  • 1
  • 8
-1

You need recent Google Play Services library project linked to your project, so during build time all resources from the project will also be available. You definitely got older library because google_play_services_version was just introduced recently. And you cannot just add jar to your project - it will not work. Just add Google Play Services as eternal library as documented.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • 1
    i have api level 19, the newest. also, i use this plugin in a simple android java applications and it works, in there, i link the lib from the google play services api, but how do i link it in unity? – Dima Dec 22 '13 at 11:37