Search code examples
androidunity-game-engineadmobintegrationgoogle-play-games

Unity Admob and Google Play Game Services integration


I tried to integrate admob and Google Play Game Services in my game, but I have got a problem. I cannot build the game. Error in console:

Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
D:\android-studio\sdk\build-tools\android-4.4W\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "D:/android-studio/sdk/platforms/android-20\android.jar" -F bin/resources.ap_ --extra-packages com.google.android.gms -S "C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res"

stderr[
res\values\maps_attrs.xml:5: error: Attribute "mapType" has already been defined
res\values\maps_attrs.xml:12: error: Attribute "cameraBearing" has already been defined
res\values\maps_attrs.xml:13: error: Attribute "cameraTargetLat" has already been defined
res\values\maps_attrs.xml:14: error: Attribute "cameraTargetLng" has already been defined
res\values\maps_attrs.xml:15: error: Attribute "cameraTilt" has already been defined
res\values\maps_attrs.xml:16: error: Attribute "cameraZoom" has already been defined
res\values\maps_attrs.xml:17: error: Attribute "uiCompass" has already been defined
res\values\maps_attrs.xml:18: error: Attribute "uiRotateGestures" has already been defined
res\values\maps_attrs.xml:19: error: Attribute "uiScrollGestures" has already been defined
res\values\maps_attrs.xml:20: error: Attribute "uiTiltGestures" has already been defined
res\values\maps_attrs.xml:21: error: Attribute "uiZoomControls" has already been defined
res\values\maps_attrs.xml:22: error: Attribute "uiZoomGestures" has already been defined
res\values\maps_attrs.xml:23: error: Attribute "useViewLifecycle" has already been defined
res\values\maps_attrs.xml:24: error: Attribute "zOrderOnTop" has already been defined
]
stdout[
Configurations:
 (default)
 hdpi
 mdpi
 xhdpi
 xxhdpi
 af
 am
 ar
 be
 bg
 ca
 cs
 da
 de
 el
 en-GB
 en-IN
 es
 es-US
 et-EE
 fa
 fi
 fr
 fr-CA
 hi
 hr
 hu
 hy-AM
 in
 it
 iw
 ja
 ka-GE
 km-KH
 ko
 lo-LA
 lt
 lv
 mn-MN
 ms-MY
 nb
 nl
 pl
 pt
 pt-BR
 pt-PT
 ro
 ru
 sk
 sl
 sr
 sv
 sw
 th
 tl
 tr
 uk
 vi
 zh-CN
 zh-HK
 zh-TW
 zu

Files:
  color\common_signin_btn_text_dark.xml
    Src: () C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\color\common_signin_btn_text_dark.xml
  color\common_signin_btn_text_light.xml
    Src: () C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\color\common_signin_btn_text_light.xml
  color\wallet_primary_text_holo_light.xml
    Src: () C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\color\wallet_primary_text_holo_light.xml
  color\wallet_secondary_text_holo_dark.xml
    Src: () C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\color\wallet_secondary_text_holo_dark.xml
  drawable\common_signin_btn_icon_dark.xml
    Src: () C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable\common_signin_btn_icon_dark.xml
  drawable\common_signin_btn_icon_disabled_dark.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_icon_disabled_dark.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_icon_disabled_dark.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_icon_disabled_dark.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_icon_disabled_dark.9.png
  drawable\common_signin_btn_icon_disabled_focus_dark.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_icon_disabled_focus_dark.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_icon_disabled_focus_dark.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_icon_disabled_focus_dark.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_icon_disabled_focus_dark.9.png
  drawable\common_signin_btn_icon_disabled_focus_light.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_icon_disabled_focus_light.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_icon_disabled_focus_light.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_icon_disabled_focus_light.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_icon_disabled_focus_light.9.png
  drawable\common_signin_btn_icon_disabled_light.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_icon_disabled_light.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_icon_disabled_light.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_icon_disabled_light.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_icon_disabled_light.9.png
  drawable\common_signin_btn_icon_focus_dark.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_icon_focus_dark.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_icon_focus_dark.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_icon_focus_dark.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_icon_focus_dark.9.png
  drawable\common_signin_btn_icon_focus_light.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_icon_focus_light.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_icon_focus_light.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_icon_focus_light.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_icon_focus_light.9.png
  drawable\common_signin_btn_icon_light.xml
    Src: () C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable\common_signin_btn_icon_light.xml
  drawable\common_signin_btn_icon_normal_dark.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_icon_normal_dark.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_icon_normal_dark.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_icon_normal_dark.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_icon_normal_dark.9.png
  drawable\common_signin_btn_icon_normal_light.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_icon_normal_light.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_icon_normal_light.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_icon_normal_light.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_icon_normal_light.9.png
  drawable\common_signin_btn_icon_pressed_dark.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_icon_pressed_dark.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_icon_pressed_dark.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_icon_pressed_dark.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_icon_pressed_dark.9.png
  drawable\common_signin_btn_icon_pressed_light.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_icon_pressed_light.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_icon_pressed_light.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_icon_pressed_light.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_icon_pressed_light.9.png
  drawable\common_signin_btn_text_dark.xml
    Src: () C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable\common_signin_btn_text_dark.xml
  drawable\common_signin_btn_text_disabled_dark.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_text_disabled_dark.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_text_disabled_dark.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_text_disabled_dark.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_text_disabled_dark.9.png
  drawable\common_signin_btn_text_disabled_focus_dark.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_text_disabled_focus_dark.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_text_disabled_focus_dark.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_text_disabled_focus_dark.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_text_disabled_focus_dark.9.png
  drawable\common_signin_btn_text_disabled_focus_light.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_text_disabled_focus_light.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_text_disabled_focus_light.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_text_disabled_focus_light.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_text_disabled_focus_light.9.png
  drawable\common_signin_btn_text_disabled_light.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_text_disabled_light.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_text_disabled_light.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_text_disabled_light.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_text_disabled_light.9.png
  drawable\common_signin_btn_text_focus_dark.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_text_focus_dark.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_text_focus_dark.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_text_focus_dark.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_text_focus_dark.9.png
  drawable\common_signin_btn_text_focus_light.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_text_focus_light.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_signin_btn_text_focus_light.9.png
    Src: (xhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xhdpi\common_signin_btn_text_focus_light.9.png
    Src: (xxhdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-xxhdpi\common_signin_btn_text_focus_light.9.png
  drawable\common_signin_btn_text_light.xml
    Src: () C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable\common_signin_btn_text_light.xml
  drawable\common_signin_btn_text_normal_dark.9.png
    Src: (hdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-hdpi\common_signin_btn_text_normal_dark.9.png
    Src: (mdpi) C:\Users\bilek993\Documents\ReklamyTest\Temp\StagingArea\android-libraries\google-play-services_lib\res\drawable-mdpi\common_sig

I used this plugin as ads and this as game services. Thanks in advance.


Solution

  • The above resources you mentioned are old. Whereas now google has official support for AdMob on Unity game engine.

    Get the official plugin here -https://github.com/googleads/googleads-mobile-plugins/blob/master/README.md

    -Import the whole package. Modify your androidmanifest.xml to include the permission and activity name.

    -Add the google-play-services_lib folder, located at /extras/google/google_play_services/libproject in your sdk, into the Plugins/Android folder of your project.

    • Code for basic banner to be included in your C# script:-

    using GoogleMobileAds.Api;

    // Create a 320x50 banner at the top of the screen.

    BannerView bannerView = new BannerView("YOUR_AD_UNIT_ID", AdSize.Banner, AdPosition.Top);

    // Create an empty ad request.

    AdRequest request = new AdRequest.Builder().Build();

    // Load the banner with the request.

    bannerView.LoadAd(request);

    And you would be able to see Ads on the top of your level on which that particular script is attached.