The question is answered, right answer was accepted
Admob problems with Android build
Hi all.
I have been experiencing problems with Admob in a 2D game in Unity. To simplify the issue, I created a new project with nothing but a basic script attached to main camera as follows:
using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;
public class AdMobScript : MonoBehaviour {
void Start()
{
RequestBanner();
}
private void RequestBanner()
{
#if UNITY_ANDROID
string adUnitId = "<my android adunitid goes here>";
#elif UNITY_IPHONE
string adUnitId = "<my ios adunitid goes here>";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.TopRight);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
bannerView.LoadAd(request);
}
}
This is actually the basic example script given here: link text
except I change my adunitids with proper values while testing the script.
When I build the project for Android, I get the following error:
Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
C:\Users\aykut.yilmaz\AppData\Local\Android\sdk\build-tools\24.0.0\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Users/aykut.yilmaz/AppData/Local/Android/sdk\platforms\android-24\android.jar" -F bin/resources.ap_ --extra-packages android.support.v7.appcompat:com.google.unity:com.google.android.gms.ads.impl:com.google.android.gms.ads:com.google.android.gms.base:com.google.android.gms:com.google.android.gms.clearcut:com.google.android.gms:com.google.android.gms.tasks:android.support.v4 -S "C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res" -S "C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\play-services-ads-9.4.0\res" -S "C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\play-services-ads-lite-9.4.0\res" -S "C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\play-services-base-9.4.0\res" -S "C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\play-services-basement-9.4.0\res" -S "C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\play-services-clearcut-9.4.0\res" -S "C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\play-services-gass-9.4.0\res" -S "C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\play-services-tasks-9.4.0\res" -S "C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\support-v4-23.1.1\res"
stderr[
]
stdout[
Configurations:
(default)
Files:
AndroidManifest.xml
Src: () AndroidManifest.xml
Resource Dirs:
Including resources from package: C:\Users\aykut.yilmaz\AppData\Local\Android\sdk\platforms\android-24\android.jar
applyFileOverlay for drawable
trying overlaySet Key=common_full_open_on_phone.png
trying overlaySet Key=common_google_signin_btn_icon_dark.xml
trying overlaySet Key=common_google_signin_btn_icon_dark_disabled.9.png
trying overlaySet Key=common_google_signin_btn_icon_dark_focused.9.png
trying overlaySet Key=common_google_signin_btn_icon_dark_normal.9.png
trying overlaySet Key=common_google_signin_btn_icon_dark_pressed.9.png
trying overlaySet Key=common_google_signin_btn_icon_light.xml
trying overlaySet Key=common_google_signin_btn_icon_light_disabled.9.png
trying overlaySet Key=common_google_signin_btn_icon_light_focused.9.png
trying overlaySet Key=common_google_signin_btn_icon_light_normal.9.png
trying overlaySet Key=common_google_signin_btn_icon_light_pressed.9.png
trying overlaySet Key=common_google_signin_btn_text_dark.xml
trying overlaySet Key=common_google_signin_btn_text_dark_disabled.9.png
trying overlaySet Key=common_google_signin_btn_text_dark_focused.9.png
trying overlaySet Key=common_google_signin_btn_text_dark_normal.9.png
trying overlaySet Key=common_google_signin_btn_text_dark_pressed.9.png
trying overlaySet Key=common_google_signin_btn_text_light.xml
trying overlaySet Key=common_google_signin_btn_text_light_disabled.9.png
trying overlaySet Key=common_google_signin_btn_text_light_focused.9.png
trying overlaySet Key=common_google_signin_btn_text_light_normal.9.png
trying overlaySet Key=common_google_signin_btn_text_light_pressed.9.png
trying overlaySet Key=common_ic_googleplayservices.png
trying overlaySet Key=common_plus_signin_btn_icon_dark.xml
trying overlaySet Key=common_plus_signin_btn_icon_dark_disabled.9.png
trying overlaySet Key=common_plus_signin_btn_icon_dark_focused.9.png
trying overlaySet Key=common_plus_signin_btn_icon_dark_normal.9.png
trying overlaySet Key=common_plus_signin_btn_icon_dark_pressed.9.png
trying overlaySet Key=common_plus_signin_btn_icon_light.xml
trying overlaySet Key=common_plus_signin_btn_icon_light_disabled.9.png
trying overlaySet Key=common_plus_signin_btn_icon_light_focused.9.png
trying overlaySet Key=common_plus_signin_btn_icon_light_normal.9.png
trying overlaySet Key=common_plus_signin_btn_icon_light_pressed.9.png
trying overlaySet Key=common_plus_signin_btn_text_dark.xml
trying overlaySet Key=common_plus_signin_btn_text_dark_disabled.9.png
trying overlaySet Key=common_plus_signin_btn_text_dark_focused.9.png
trying overlaySet Key=common_plus_signin_btn_text_dark_normal.9.png
trying overlaySet Key=common_plus_signin_btn_text_dark_pressed.9.png
trying overlaySet Key=common_plus_signin_btn_text_light.xml
trying overlaySet Key=common_plus_signin_btn_text_light_disabled.9.png
trying overlaySet Key=common_plus_signin_btn_text_light_focused.9.png
trying overlaySet Key=common_plus_signin_btn_text_light_normal.9.png
trying overlaySet Key=common_plus_signin_btn_text_light_pressed.9.png
trying overlaySet Key=abc_ab_share_pack_mtrl_alpha.9.png
trying overlaySet Key=abc_action_bar_item_background_material.xml
trying overlaySet Key=abc_btn_borderless_material.xml
trying overlaySet Key=abc_btn_check_material.xml
trying overlaySet Key=abc_btn_check_to_on_mtrl_000.png
trying overlaySet Key=abc_btn_check_to_on_mtrl_015.png
trying overlaySet Key=abc_btn_colored_material.xml
trying overlaySet Key=abc_btn_default_mtrl_shape.xml
trying overlaySet Key=abc_btn_radio_material.xml
trying overlaySet Key=abc_btn_radio_to_on_mtrl_000.png
trying overlaySet Key=abc_btn_radio_to_on_mtrl_015.png
trying overlaySet Key=abc_btn_rating_star_off_mtrl_alpha.png
trying overlaySet Key=abc_btn_rating_star_on_mtrl_alpha.png
trying overlaySet Key=abc_btn_switch_to_on_mtrl_00001.9.png
trying overlaySet Key=abc_btn_switch_to_on_mtrl_00012.9.png
trying overlaySet Key=abc_cab_background_internal_bg.xml
trying overlaySet Key=abc_cab_background_top_material.xml
trying overlaySet Key=abc_cab_background_top_mtrl_alpha.9.png
trying overlaySet Key=abc_control_background_material.xml
trying overlaySet Key=abc_dialog_material_background_dark.xml
trying overlaySet Key=abc_dialog_material_background_light.xml
trying overlaySet Key=abc_edit_text_material.xml
trying overlaySet Key=abc_ic_ab_back_mtrl_am_alpha.png
trying overlaySet Key=abc_ic_clear_mtrl_alpha.png
trying overlaySet Key=abc_ic_commit_search_api_mtrl_alpha.png
trying overlaySet Key=abc_ic_go_search_api_mtrl_alpha.png
trying overlaySet Key=abc_ic_menu_copy_mtrl_am_alpha.png
trying overlaySet Key=abc_ic_menu_cut_mtrl_alpha.png
trying overlaySet Key=abc_ic_menu_moreoverflow_mtrl_alpha.png
trying overlaySet Key=abc_ic_menu_paste_mtrl_am_alpha.png
trying overlaySet Key=abc_ic_menu_selectall_mtrl_alpha.png
trying overlaySet Key=abc_ic_menu_share_mtrl_alpha.png
trying overlaySet Key=abc_ic_search_api_mtrl_alpha.png
trying overlaySet Key=abc_ic_voice_search_api_mtrl_alpha.png
trying overlaySet Key=abc_item_background_holo_dark.xml
trying overlaySet Key=abc_item_background_holo_light.xml
trying overlaySet Key=abc_list_divider_mtrl_alpha.9.png
trying overlaySet Key=abc_list_focused_holo.9.png
trying overlaySet Key=abc_list_longpressed_holo.9.png
trying overlaySet Key=abc_list_pressed_holo_dark.9.png
trying overlaySet Key=abc_list_pressed_holo_light.9.png
trying overlaySet Key=abc_list_selector_background_transition_holo_dark.xml
trying overlaySet Key=abc_list_selector_background_transition_holo_light.xml
trying overlaySet Key=abc_list_selector_disabled_holo_dark.9.png
trying overlaySet Key=abc_list_selector_disabled_holo_light.9.png
trying overlaySet Key=abc_list_selector_holo_dark.xml
trying overlaySet Key=abc_list_selector_holo_light.xml
trying overlaySet Key=abc_menu_hardkey_panel_mtrl_mult.9.png
trying overlaySet Key=abc_popup_background_mtrl_mult.9.png
trying overlaySet Key=abc_ratingbar_full_material.xml
trying overlaySet Key=abc_scrubber_control_off_mtrl_alpha.png
trying overlaySet Key=abc_scrubber_control_to_pressed_mtrl_000.png
trying overlaySet Key=abc_scrubber_control_to_pressed_mtrl_005.png
trying overlaySet Key=abc_scrubber_primary_mtrl_alpha.9.png
trying overlaySet Key=abc_scrubber_track_mtrl_alpha.9.png
trying overlaySet Key=abc_seekbar_thumb_material.xml
trying overlaySet Key=abc_seekbar_track_material.xml
trying overlaySet Key=abc_spinner_mtrl_am_alpha.9.png
trying overlaySet Key=abc_spinner_textfield_background_material.xml
trying overlaySet Key=abc_switch_thumb_material.xml
trying overlaySet Key=abc_switch_track_mtrl_alpha.9.png
trying overlaySet Key=abc_tab_indicator_material.xml
trying overlaySet Key=abc_tab_indicator_mtrl_alpha.9.png
trying overlaySet Key=abc_text_cursor_material.xml
trying overlaySet Key=abc_textfield_activated_mtrl_alpha.9.png
trying overlaySet Key=abc_textfield_default_mtrl_alpha.9.png
trying overlaySet Key=abc_textfield_search_activated_mtrl_alpha.9.png
trying overlaySet Key=abc_textfield_search_default_mtrl_alpha.9.png
trying overlaySet Key=abc_textfield_search_material.xml
trying overlaySet Key=app_banner.png
trying overlaySet Key=app_icon.png
applyFileOverlay for layout
trying overlaySet Key=abc_action_bar_title_item.xml
trying overlaySet Key=abc_action_bar_up_container.xml
trying overlaySet Key=abc_action_bar_view_list_nav_layout.xml
trying overlaySet Key=abc_action_menu_item_layout.xml
trying overlaySet Key=abc_action_menu_layout.xml
trying overlaySet Key=abc_action_mode_bar.xml
trying overlaySet Key=abc_action_mode_close_item_material.xml
trying overlaySet Key=abc_activity_chooser_view.xml
trying overlaySet Key=abc_activity_chooser_view_list_item.xml
trying overlaySet Key=abc_alert_dialog_button_bar_material.xml
trying overlaySet Key=abc_alert_dialog_material.xml
trying overlaySet Key=abc_dialog_title_material.xml
trying overlaySet Key=abc_expanded_menu_layout.xml
trying overlaySet Key=abc_list_menu_item_checkbox.xml
trying overlaySet Key=abc_list_menu_item_icon.xml
trying overlaySet Key=abc_list_menu_item_layout.xml
trying overlaySet Key=abc_list_menu_item_radio.xml
trying overlaySet Key=abc_popup_menu_item_layout.xml
trying overlaySet Key=abc_screen_content_include.xml
trying overlaySet Key=abc_screen_simple.xml
trying overlaySet Key=abc_screen_simple_overlay_action_mode.xml
trying overlaySet Key=abc_screen_toolbar.xml
trying overlaySet Key=abc_search_dropdown_item_icons_2line.xml
trying overlaySet Key=abc_search_view.xml
trying overlaySet Key=abc_select_dialog_material.xml
trying overlaySet Key=notification_media_action.xml
trying overlaySet Key=notification_media_cancel_action.xml
trying overlaySet Key=notification_template_big_media.xml
trying overlaySet Key=notification_template_big_media_narrow.xml
trying overlaySet Key=notification_template_lines.xml
trying overlaySet Key=notification_template_media.xml
trying overlaySet Key=notification_template_part_chronometer.xml
trying overlaySet Key=notification_template_part_time.xml
trying overlaySet Key=select_dialog_item_material.xml
trying overlaySet Key=select_dialog_multichoice_material.xml
trying overlaySet Key=select_dialog_singlechoice_material.xml
trying overlaySet Key=support_simple_spinner_dropdown_item.xml
applyFileOverlay for anim
trying overlaySet Key=abc_fade_in.xml
trying overlaySet Key=abc_fade_out.xml
trying overlaySet Key=abc_grow_fade_in_from_bottom.xml
trying overlaySet Key=abc_popup_enter.xml
trying overlaySet Key=abc_popup_exit.xml
trying overlaySet Key=abc_shrink_fade_out_from_bottom.xml
trying overlaySet Key=abc_slide_in_bottom.xml
trying overlaySet Key=abc_slide_in_top.xml
trying overlaySet Key=abc_slide_out_bottom.xml
trying overlaySet Key=abc_slide_out_top.xml
applyFileOverlay for animator
applyFileOverlay for interpolator
applyFileOverlay for transition
applyFileOverlay for xml
applyFileOverlay for raw
applyFileOverlay for color
trying overlaySet Key=common_google_signin_btn_text_dark.xml
trying overlaySet Key=common_google_signin_btn_text_light.xml
trying overlaySet Key=common_plus_signin_btn_text_dark.xml
trying overlaySet Key=common_plus_signin_btn_text_light.xml
trying overlaySet Key=abc_background_cache_hint_selector_material_dark.xml
trying overlaySet Key=abc_background_cache_hint_selector_material_light.xml
trying overlaySet Key=abc_color_highlight_material.xml
trying overlaySet Key=abc_primary_text_disable_only_material_dark.xml
trying overlaySet Key=abc_primary_text_disable_only_material_light.xml
trying overlaySet Key=abc_primary_text_material_dark.xml
trying overlaySet Key=abc_primary_text_material_light.xml
trying overlaySet Key=abc_search_url_text.xml
trying overlaySet Key=abc_secondary_text_material_dark.xml
trying overlaySet Key=abc_secondary_text_material_light.xml
trying overlaySet Key=switch_thumb_material_dark.xml
trying overlaySet Key=switch_thumb_material_light.xml
applyFileOverlay for menu
applyFileOverlay for mipmap
Processing image: C:\Users\ayPrkoucte.sysiilnmga zi\mDaogceu:m entCs:\\AUyskeurts\\Uanyiktuyt .Pyrioljmeaczt\sD\oAcdummoebn tTse\sAytk\uTte\mUpn\iSttya gPirnogjAercetas\\aAnddmroobi dTe-slitb\rTaerimeps\\SatpapgcionmgpAarte-av\7android-libraries\appcompat-v7-23.1.1\res\drawable-hdpi\abc_ab-_2s3h.a1r.e1_\praecsk\_dmrtarwla_ballep-hmad.p9i.\panbgc
_ab_share_pack_mtrl_alpha.9.png
Processing image: C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-xhdpi\abc_ab_share_pack_mtrl_alpha.9.png
Processing image: C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-xxhdpi\abc_ab_share_pack_mtrl_alpha.9.png
(processed image C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-mdpi\abc_ab_share_pack_mtrl_alpha.9.png: 253% size of source)
(processed image C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\dPrrawoceasbslei-nhdg piim\aabgce: _aCb:_\sUsehrasre\_apacykk_umtt.yrillm_aaz\lDphoacu.m9e.nptnsg\:A ykut\U2n5i6t%y Psriozje eocfts s\oAudrmcobe )Te
st\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-mdpi\abc_btn_check_to_on_mtrl_000.png
(processed image C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-xhdpi\abc_ab_share_pack_mtrl_alpha.9.png: 253% size of source)
Processing image: C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-hdpi\abc_btn_check_to_on_mtrl_000.png
(processed image C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-xxhdpi\abc_ab_share_pack_mtrl_alpha.9.png: 236% size of source)
(processed image C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-mdpi\abc_btn_check_to_on_mtrl_000.png: 134% size of source)
Processing image: C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-xhdpi\abc_btn_check_to_on_mtrl_000.png
Processing image: C:\Users\aykutP.ryoiclemsaszi\nDgo cuimmeangtes:\ AykuCt:\\UUnsietrys \Paryokjuetc.tysi\lAmdamzo\bD oTceusmte\nTtesm\pA\ySktuatg\iUnngiAtrye aP\raonjdercotisd\-Aldimborba rTieesst\\aTpepmcpo\mSptaatg-ivn7g-A2r3e.a1\.a1n\drreosi\dd-rlaiwbarbalrei-exsx\hadpppic\oambpca_tb-tvn7_-c2h3e.c1k._1t\or_eosn\_dmrtarwla_b0l0e0-.xpxnxgh
dpi\abc_btn_check_to_on_mtrl_000.png
(processed image C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-hdpi\abc_btn_check_to_on_mtrl_000.png: 134% size of source)
(processed image C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-xhdpi\abc_btn_check_to_on_mtrl_000.png: 125% size of source)
Processing image: C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res\drawable-mdpi\abc_btn_check_to_on_mtrl_015.png
Processing image: C:\Users\aykut.yilmaz\Documents\Aykut\Unity Projects\Admob Test\Temp\StagingArea\android<message truncated>
My Unity version is 5.3.6f1 Personal, Android Studio 2.1.2, Google Mobile Ads Unity Plugin v3.0.5 and on my console I get resolver version is 10102.
Upgrading Unity to 5.4.0f3 corrupted my project so that is not an option for now.
How can I debug this problem from here?
Answer by liortal · Aug 16, 2016 at 08:07 PM
A few things to check:
There used to be an issue if i recall with Android build tools 24.0.0. You should upgrade and use 24.0.1, that may solve the issue.
The error message is truncated (see it even says so at the end). You should post the full error message, by opening the Editor Log (from Unity console window -> Click on the lines icon in its corner, and from there open the Editor log). This file should not be truncated and should contain the full error message.
Answer by aykut-yilmaz · Aug 17, 2016 at 10:45 AM
Upgrading to Android Build Tools 24.0.1 required a chain of other upgrades but finally my problem is solved.
I upgraded Android Build Tools to 24.0.1. This required me to upgrade Java from 1.7 (7u79) to 1.8 (8u101).
During the process Android Studio asked for an upgrade to 2.1.3 due to a security fix and Gradle required an upgrade to 2.14.1.
With this final configuration my problem disappeared both on the small test project and my main project.
Thank you very much liortal.