Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug Android 12 App crashes on startup due to error with PendingIntent (Google Mobile Ads plugin used)

Discussion in 'Android' started by Guambo1, Dec 23, 2021.

  1. Guambo1

    Guambo1

    Joined:
    Jun 24, 2018
    Posts:
    9
    My unity project uses Google Ad Mob Unity Plugin v6.1.2 which is the latest version.
    Target api level is 31.
    The game runs fine on devices that run Android 8.0 to 11.0.
    Using Unity 2020.3.25f1.

    I am running an android emulator through Android Studio that uses a Pixel3a android api level 31 (Android 12) to run my unity game and this is what Logcat spits back at me upon launching the app (Take a look at line 4 & line 5):


    Code (csharp):
    1.  
    2. 2021-12-22 21:42:27.599 9019-9038/? E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
    3.     Process: com.Guambo.GooRunner, PID: 9019
    4.     java.lang.IllegalArgumentException: com.Guambo.GooRunner: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    5.     Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    6.         at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
    7.         at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
    8.         at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
    9.         at androidx.work.impl.utils.ForceStopRunnable.a(Unknown Source:5)
    10.         at androidx.work.impl.utils.ForceStopRunnable.a(Unknown Source:4)
    11.         at androidx.work.impl.utils.ForceStopRunnable.run(Unknown Source:52)
    12.         at androidx.work.impl.utils.f$a.run(Unknown Source:2)
    13.         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    14.         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    15.         at java.lang.Thread.run(Thread.java:920)
    16.  
    After scouring the web I found this stackoverflow answer and tried to add this WorkManager dependency to the mainTemplate.gradle file in Unity (In Unity, set the following checkbox to true to create a custom main gradle template file called mainTemplate.gradle: ProjectSettings>PlayerSettings>PublishingSettings>Build>Custom Main Gradle Template).

    However, even after adding this dependency to the projects gradle file, I still encounter the error above.
    So I am thinking that somewhere through the use of the Google Mobile Ads Unity Plugin, they are creating an object of type PendingIntent and not specifing FLAG_IMMUTABLE or FLAG_MUTABLE.

    The type of Ad that I am running is a rewarded ad. Here is all Google Mobile Ad related code in my unity project:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Events;
    5. using GoogleMobileAds.Api;
    6. using System;
    7.  
    8. // https://developers.google.com/admob/unity/quick-start
    9. // Rewarded Ads - https://developers.google.com/admob/unity/rewarded
    10. // Sample Impl - https://github.com/googleads/googleads-mobile-unity/blob/master/samples/HelloWorld/Assets/Scripts/GoogleAdMobController.cs
    11. public class GoogleAdsController : MonoBehaviour
    12. {
    13.     private RewardedAd rewardedAd;
    14.     public UnityEvent OnAdLoadedEvent;
    15.     public UnityEvent OnAdFailedToLoadEvent;
    16.     public UnityEvent OnUserEarnedRewardEvent;
    17.     public UnityEvent OnAdClosedEvent;
    18.  
    19.     void Start()
    20.     {
    21.         // Make sure to set ads to be kid friendly
    22.         RequestConfiguration requestConfiguration =
    23.             new RequestConfiguration.Builder()
    24.             .SetTagForChildDirectedTreatment(TagForChildDirectedTreatment.True)
    25.             .SetMaxAdContentRating(MaxAdContentRating.G)
    26.             .build();
    27.         MobileAds.SetRequestConfiguration(requestConfiguration);
    28.  
    29.         // Initialize the Google Mobile Ads SDK
    30.         MobileAds.Initialize(initStatus => { });
    31.  
    32.         // Load an Ad
    33.         rewardedAd = RequestAndLoadRewardedAd();
    34.     }
    35.     // Load an rewarded Ad
    36.     public RewardedAd RequestAndLoadRewardedAd()
    37.     {
    38.         // The following adUnitId is a test ad, in my actual game build I am using a valid adUnitId
    39.         // I just changed it for the unity forum post
    40.         string adUnitId = "ca-app-pub-3940256099942544/5224354917";
    41.  
    42.         // Create new rewarded ad instance
    43.         RewardedAd rewardedAd = new RewardedAd(adUnitId);
    44.  
    45.         // Add Event Handlers (https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html)
    46.         rewardedAd.OnAdLoaded += (sender, args) => OnAdLoadedEvent.Invoke();
    47.         rewardedAd.OnAdFailedToLoad += (sender, args) => OnAdFailedToLoadEvent.Invoke();
    48.         rewardedAd.OnUserEarnedReward += (sender, args) => OnUserEarnedRewardEvent.Invoke();
    49.         rewardedAd.OnAdClosed += (sender, args) => OnAdClosedEvent.Invoke();
    50.  
    51.         // Create empty ad request
    52.         rewardedAd.LoadAd(CreateAdRequest());
    53.         // Return rewarded ad
    54.         return rewardedAd;
    55.     }
    56.    
    57.     // Show the rewarded Ad
    58.     public void ShowRewardedAd()
    59.     {
    60.         if (rewardedAd != null)
    61.         {
    62.             if (rewardedAd.IsLoaded())
    63.                 rewardedAd.Show();
    64.         }
    65.     }
    66.  
    67.     private AdRequest CreateAdRequest()
    68.     {
    69.         return new AdRequest.Builder()
    70.             .AddExtra("max_ad_content_rating", "G")
    71.             .AddExtra("is_designed_for_families", "true")
    72.             .Build();
    73.     }
    74.  
    75.     // On Closed
    76.     public void OnAdClosed()
    77.     {
    78.         // Debug.Log("Loading new ad");
    79.         // Load up a new ad
    80.         rewardedAd = RequestAndLoadRewardedAd();
    81.     }
    82. }
    I am not running any other plugins, I am not making a notification calls. So I have no idea where else a PendingIntent could be made other than through the Google Mobile Ads internal code.
     
    Jimaniki likes this.
  2. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,992
    Starting Android 12, any Pending Intents creation needs Mutability flags. Look if any updates published for those plugins to get it resolved.
     
    Guambo1 likes this.
  3. Guambo1

    Guambo1

    Joined:
    Jun 24, 2018
    Posts:
    9
    Found the official release notes to fix this issue if anyone happens to stumble upon this thread:
    https://developers.google.com/admob/android/rel-notes

    Basically, in unity you need to edit the mainTemplate.gradle file to include the dependencies mentioned in the above link.

    1. In Unity, set the following checkbox to true to create a custom main gradle template file called mainTemplate.gradle: ProjectSettings>PlayerSettings>PublishingSettings>Build>Custom Main Gradle Template
    2. In mainTemplate.gradle go to the dependencies section and change it to this:
    Code (CSharp):
    1.  
    2. dependencies {
    3.   implementation 'com.google.android.gms:play-services-ads:20.4.0'
    4.  
    5.   // For apps targeting Android 12, add WorkManager dependency.
    6.   constraints {
    7.    implementation('androidx.work:work-runtime:2.7.0') {
    8.      because '''androidx.work:work-runtime:2.1.0 pulled from
    9.     play-services-ads has a bug using PendingIntent without
    10.     FLAG_IMMUTABLE or FLAG_MUTABLE and will fail in Apps
    11.     targeting S+.'''
    12.    }
    13.   }
    14. }
    15.  
     
    ayseaktas, hisham2, Baykus and 5 others like this.
  4. unity_EfGoW0qPNcl2RA

    unity_EfGoW0qPNcl2RA

    Joined:
    Mar 11, 2019
    Posts:
    1
    This worked for me! Thank you very much.
     
    Guambo1 likes this.
  5. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    I can't get this to work, where am I supposed to paste it? I'm having issues with Google AdMob and/or Yodo1
     
  6. partimejobnaveed

    partimejobnaveed

    Joined:
    Nov 30, 2020
    Posts:
    5
    Hello brother. Would you like to send me your current manifest, gradle Templete and gradle properties template if any. i actually tried this but now build is not being generated sadly
     
  7. soulcryy

    soulcryy

    Joined:
    Sep 15, 2020
    Posts:
    9
    @Guambo1, thank you very much that worked for me.

    @partimejobnaveed, below is my gradle template dependencies.

    Code (CSharp):
    1. dependencies {
    2.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    3.     implementation 'com.google.android.gms:play-services-ads:20.4.0'
    4.     constraints {
    5.         implementation('androidx.work:work-runtime:2.7.0') {
    6.             because '''androidx.work:work-runtime:2.1.0 pulled from
    7.            play-services-ads has a bug using PendingIntent without
    8.            FLAG_IMMUTABLE or FLAG_MUTABLE and will fail in Apps
    9.            targeting S+.'''
    10.         }
    11.     }
    12. // Android Resolver Dependencies End
    13. **DEPS**
    14. }
    15.  

    But please note, when I applied it, it was failing to build. Additionally I had to add below to my gradleTemplate.properties
    Code (CSharp):
    1. android.useAndroidX=true
    2. android.enableJetifier=true
    I hope this will help you.

    Edit: Apparently something reverted my gradle template. I made correction on that part.
     
    Last edited: Feb 9, 2022
    Guambo1, khanism and partimejobnaveed like this.
  8. partimejobnaveed

    partimejobnaveed

    Joined:
    Nov 30, 2020
    Posts:
    5
    //Thank you so much dude. I'll definitely try this again. Thanks again :)
     
  9. mahmoud93p

    mahmoud93p

    Joined:
    Feb 11, 2015
    Posts:
    66
    1- Update Firebase if you have.
    2- Update Admob.
    3- Delete all file "il2cpp"
    A -Go to your project path /Library/il2cpp_android_arm64-v8a
    B- Delete ~/Library/il2cpp_android_armeabi-v7a
    C- Delete ~/Library//Il2cppBuildCache
    4- Before Enable mainTemplate.gradle you must Enable "Custom Gradle properties Template" first.
    5- You must know what is your admob version before copy this line

    Code (CSharp):
    1.  
    2. implementation 'com.google.android.gms:play-services-ads:20.4.0'
    3.     constraints {
    4.         implementation('androidx.work:work-runtime:2.7.0') {
    5.             because '''androidx.work:work-runtime:2.1.0 pulled from
    6.           play-services-ads has a bug using PendingIntent without
    7.           FLAG_IMMUTABLE or FLAG_MUTABLE and will fail in Apps
    8.           targeting S+.'''
    9.         }
    10.     }
    You Can found your admob version from "mainTemplate.gradle"
    For me like that :
    Code (CSharp):
    1.   implementation 'com.google.android.gms:play-services-ads:20.6.0'
    2.     constraints {
    3.         implementation('androidx.work:work-runtime:2.7.0') {
    4.             because '''androidx.work:work-runtime:2.1.0 pulled from
    5.           play-services-ads has a bug using PendingIntent without
    6.           FLAG_IMMUTABLE or FLAG_MUTABLE and will fail in Apps
    7.           targeting S+.'''
    8.         }
    9.     }
    6- for me "Api Compatibility Level" .Net 4.x "I'm not sure if will affect "
    7- Be patient
    8- Be patient
    9- Be patient
    10- Say I hate Android
    11- Say thank you for @Guambo1
    Thank you Guambo1

     
    Last edited: Mar 27, 2022
  10. hasnain7734

    hasnain7734

    Joined:
    Jan 17, 2022
    Posts:
    2
    Thanks @Guambo1

    one more thing you should use your admob ad version in first line instead of "20..6.0" because I was having this issue.
    1. implementation 'com.google.android.gms:play-services-ads:20.6.0'
    2. constraints {
    3. implementation('androidx.work:work-runtime:2.7.0') {
    4. because '''androidx.work:work-runtime:2.1.0 pulled from
    5. play-services-ads has a bug using PendingIntent without
    6. FLAG_IMMUTABLE or FLAG_MUTABLE and will fail in Apps
    7. targeting S+.'''
    8. }
    9. }
     
    Guambo1 likes this.
  11. krushnagodhania0101

    krushnagodhania0101

    Joined:
    Apr 6, 2020
    Posts:
    2
    MY FRIEND YOU ARE A GIFT FROM GOD.
     
    Guambo1 likes this.
  12. Archi_16

    Archi_16

    Joined:
    Apr 7, 2017
    Posts:
    87
    not working for me at all. after build it says to many errors.
    any other solution?
     
  13. Michelle_Ca

    Michelle_Ca

    Joined:
    Aug 19, 2019
    Posts:
    113
    hi, i'm using (unity 2019.4.40f1 LTS) the solution only worked for me once and when i tried again to build with same (project settings) and (mainTemplate.gradle) and Enabled (Custom Gradle properties Template). it gave 5 errors.
    first 3 errors :
    Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details

    > Configure project :launcher
    WARNING: The option setting 'android.bundle.enableUncompressedNativeLibs=false' is experimental and unsupported.
    The current default is 'true'.

    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-30\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-30\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only

    > Configure project :unityLibrary
    WARNING: The option setting 'android.bundle.enableUncompressedNativeLibs=false' is experimental and unsupported.
    The current default is 'true'.


    > Configure project :unityLibrary:GoogleMobileAdsPlugin.androidlib
    WARNING: The option setting 'android.bundle.enableUncompressedNativeLibs=false' is experimental and unsupported.
    The current default is 'true'.


    > Configure project :unityLibrary:GooglePlayGamesManifest.plugin
    WARNING: The option setting 'android.bundle.enableUncompressedNativeLibs=false' is experimental and unsupported.
    The current default is 'true'.


    UnityEngine.GUIUtility:processEvent (int,intptr)
    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not determine the dependencies of task ':launcher:preReleaseBuild'.
    > Could not resolve all task dependencies for configuration ':launcher:releaseRuntimeClasspath'.
    > Could not resolve com.google.android.gms:play-services-ads-base:[19.5.0].
    Required by:
    project :launcher > project :unityLibrary > com.google.android.gms:play-services-ads:19.5.0
    > Failed to list versions for com.google.android.gms:play-services-ads-base.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml'. Received status code 403 from server: Forbidden
    > Failed to list versions for com.google.android.gms:play-services-ads-base.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml'. Received status code 403 from server: Forbidden
    > Could not resolve com.google.android.gms:play-services-ads-lite:[19.5.0].
    Required by:
    project :launcher > project :unityLibrary > com.google.android.gms:play-services-ads:19.5.0
    > Failed to list versions for com.google.android.gms:play-services-ads-lite.
    > Unable to load Maven meta-data from https://dl.google.com/dl/android/ma...gms/play-services-ads-lite/maven-metadata.xml.
    > Could not HEAD 'https://dl.google.com/dl/android/ma...gms/play-services-ads-lite/maven-metadata.xml'.
    > Remote host closed connection during handshake
    > Failed to list versions for com.google.android.gms:play-services-ads-lite.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml'. Received status code 403 from server: Forbidden
    > Failed to list versions for com.google.android.gms:play-services-ads-lite.
    > Unable to load Maven meta-data from https://maven.google.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml.
    > Could not HEAD 'https://dl.google.com/dl/android/ma...gms/play-services-ads-lite/maven-metadata.xml'.
    > Remote host closed connection during handshake
    > Failed to list versions for com.google.android.gms:play-services-ads-lite.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml'. Received status code 403 from server: Forbidden
    > Could not resolve com.google.android.gms:play-services-gass:[19.5.0].
    Required by:
    project :launcher > project :unityLibrary > com.google.android.gms:play-services-ads:19.5.0
    > Failed to list versions for com.google.android.gms:play-services-gass.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml'. Received status code 403 from server: Forbidden
    > Failed to list versions for com.google.android.gms:play-services-gass.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml'. Received status code 403 from server: Forbidden

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    * Get more help at https://help.gradle.org

    BUILD FAILED in 1m 24s
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

    UnityEngine.GUIUtility:processEvent (int,intptr)
    CommandInvokationFailure: Gradle build failed.
    C:/Program Files/Unity/Editor/2019.4.40f1/Editor/Data/PlaybackEngines/AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "bundleRelease"

    stderr[

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not determine the dependencies of task ':launcher:preReleaseBuild'.
    > Could not resolve all task dependencies for configuration ':launcher:releaseRuntimeClasspath'.
    > Could not resolve com.google.android.gms:play-services-ads-base:[19.5.0].
    Required by:
    project :launcher > project :unityLibrary > com.google.android.gms:play-services-ads:19.5.0
    > Failed to list versions for com.google.android.gms:play-services-ads-base.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml'. Received status code 403 from server: Forbidden
    > Failed to list versions for com.google.android.gms:play-services-ads-base.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-base/maven-metadata.xml'. Received status code 403 from server: Forbidden
    > Could not resolve com.google.android.gms:play-services-ads-lite:[19.5.0].
    Required by:
    project :launcher > project :unityLibrary > com.google.android.gms:play-services-ads:19.5.0
    > Failed to list versions for com.google.android.gms:play-services-ads-lite.
    > Unable to load Maven meta-data from https://dl.google.com/dl/android/ma...gms/play-services-ads-lite/maven-metadata.xml.
    > Could not HEAD 'https://dl.google.com/dl/android/ma...gms/play-services-ads-lite/maven-metadata.xml'.
    > Remote host closed connection during handshake
    > Failed to list versions for com.google.android.gms:play-services-ads-lite.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml'. Received status code 403 from server: Forbidden
    > Failed to list versions for com.google.android.gms:play-services-ads-lite.
    > Unable to load Maven meta-data from https://maven.google.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml.
    > Could not HEAD 'https://dl.google.com/dl/android/ma...gms/play-services-ads-lite/maven-metadata.xml'.
    > Remote host closed connection during handshake
    > Failed to list versions for com.google.android.gms:play-services-ads-lite.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-lite/maven-metadata.xml'. Received status code 403 from server: Forbidden
    > Could not resolve com.google.android.gms:play-services-gass:[19.5.0].
    Required by:
    project :launcher > project :unityLibrary > com.google.android.gms:play-services-ads:19.5.0
    > Failed to list versions for com.google.android.gms:play-services-gass.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml'. Received status code 403 from server: Forbidden
    > Failed to list versions for com.google.android.gms:play-services-gass.
    > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml.
    > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml'.
    > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-gass/maven-metadata.xml'. Received status code 403 from server: Forbidden

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    * Get more help at https://help.gradle.org

    BUILD FAILED in 1m 24s
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    ]
    stdout[
    Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details

    > Configure project :launcher
    WARNING: The option setting 'android.bundle.enableUncompressedNativeLibs=false' is experimental and unsupported.
    The current default is 'true'.

    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-30\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-30\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Editor\2019.4.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only

    > Configure project :unityLibrary
    WARNING: The option setting 'android.bundle.enableUncompressedNativeLibs=false' is experimental and unsupported.
    The current default is 'true'.


    > Configure project :unityLibrary:GoogleMobileAdsPlugin.androidlib
    WARNING: The option setting 'android.bundle.enableUncompressedNativeLibs=false' is experimental and unsupported.
    The current default is 'true'.


    > Configure project :unityLibrary:GooglePlayGamesManifest.plugin
    WARNING: The option setting 'android.bundle.enableUncompressedNativeLibs=false' is experimental and unsupported.
    The current default is 'true'.

    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    Rethrow as GradleInvokationException: Gradle build failed
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
    UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <dd2e71f8d45046b88d6d3169a8084aec>:0)
    UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <7105be432fb64891b07085914e6cd5c1>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
    Jimaniki likes this.
  14. rohitvishwakarma1819

    rohitvishwakarma1819

    Joined:
    Feb 15, 2018
    Posts:
    14
    @mahmoud93p I went your step by steps and it worked. thanks
     
  15. AllanRW

    AllanRW

    Joined:
    Nov 6, 2014
    Posts:
    37
    Same errors, in my case updating Firebase and Admob to latest plugin version solve the problem.
     
  16. mahmoud93p

    mahmoud93p

    Joined:
    Feb 11, 2015
    Posts:
    66
    After i do those steps i get "AdMob policy violation, type is "Modified ad behavior", that it's happened for me after few months.

    And i fixed by update admob sdk and i don't make any change.
    ** don't make any change in "Custom Gradle properties Template"
     
    Guambo1 likes this.
  17. luciano_unity

    luciano_unity

    Joined:
    Nov 4, 2017
    Posts:
    7
    Heads up, I fixed this by upgrading play-services-ads. As stated in one of the posts above, an earlier version has this problem.
     
    Guambo1 likes this.
  18. Guambo1

    Guambo1

    Joined:
    Jun 24, 2018
    Posts:
    9
    Hey yall just stopping by after having not signed into unity forums in close to a YEAR! Im glad I was able to help everyone with this - took a lot of digging to figure this issue out when I was making an update to my google play game Goo Runner last December. Im glad the most up to date official admob unity sdk patched this issue!
     
  19. pashok77007

    pashok77007

    Joined:
    Oct 30, 2015
    Posts:
    15
    My mainTemplate.gradle (dependencies):
    Code (CSharp):
    1. dependencies {
    2.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    3. // Android Resolver Dependencies Start
    4.     implementation 'androidx.lifecycle:lifecycle-common-java8:2.4.1' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12
    5.     implementation 'androidx.lifecycle:lifecycle-process:2.4.1' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:17
    6.     implementation 'com.google.android.gms:play-services-ads:21.3.0' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
    7.     implementation 'com.google.android.gms:play-services-base:18.1.0' // Assets/Firebase/Editor/AppDependencies.xml:17
    8.     implementation 'com.google.firebase:firebase-analytics:21.2.0' // Assets/Firebase/Editor/AppDependencies.xml:15
    9.     implementation 'com.google.firebase:firebase-analytics-unity:10.3.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
    10.     implementation 'com.google.firebase:firebase-app-unity:10.3.0' // Assets/Firebase/Editor/AppDependencies.xml:22
    11.     implementation 'com.google.firebase:firebase-common:20.2.0' // Assets/Firebase/Editor/AppDependencies.xml:13
    12. // Android Resolver Dependencies End
    13. **DEPS**}
    Is this the correct version of my code modification?
    Code (CSharp):
    1. dependencies {
    2.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    3. // Android Resolver Dependencies Start
    4.     implementation 'androidx.lifecycle:lifecycle-common-java8:2.4.1' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12
    5.     implementation 'androidx.lifecycle:lifecycle-process:2.4.1' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:17
    6.     implementation 'com.google.android.gms:play-services-ads:21.3.0' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
    7.  
    8.     // For apps targeting Android 12, add WorkManager dependency.
    9.     constraints {
    10.         implementation('androidx.work:work-runtime:2.7.0') {
    11.             because '''androidx.work:work-runtime:2.1.0 pulled from
    12.            play-services-ads has a bug using PendingIntent without
    13.            FLAG_IMMUTABLE or FLAG_MUTABLE and will fail in Apps
    14.            targeting S+.'''
    15.         }
    16.     }
    17.  
    18.     implementation 'com.google.android.gms:play-services-base:18.1.0' // Assets/Firebase/Editor/AppDependencies.xml:17
    19.     implementation 'com.google.firebase:firebase-analytics:21.2.0' // Assets/Firebase/Editor/AppDependencies.xml:15
    20.     implementation 'com.google.firebase:firebase-analytics-unity:10.3.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
    21.     implementation 'com.google.firebase:firebase-app-unity:10.3.0' // Assets/Firebase/Editor/AppDependencies.xml:22
    22.     implementation 'com.google.firebase:firebase-common:20.2.0' // Assets/Firebase/Editor/AppDependencies.xml:13
    23. // Android Resolver Dependencies End
    24. **DEPS**}
    Help! I am tormented with this problem.
    I tried it in different ways, maybe the fact is that my version
    of play-services-ads:21.3.0 and not 20.4.0 like yours?

    my unity 2021.3.16f1 my error when running on Android, it only occurs when API >30
    But google play only allows downloading from API >30 I can't update the app in GooglePlay:
    Code (CSharp):
    1. 2022/12/30 18:21:17.308 25761 25761 Warn UnityMain type=1400 audit(0.0:3400041): avc: denied { search } for name="mqsas" dev="dm-15" ino=566 scontext=u:r:untrusted_app:s0:c113,c257,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.polygon.BattleSimulator
    IT'S DECIDED. The error disappeared when updating unity from 2021.3.16a1 to 2022.2.1a1 everything is perfect!
     
    Last edited: Jan 1, 2023
  20. Husamettin

    Husamettin

    Joined:
    Oct 1, 2019
    Posts:
    4
    I have the same problem but can't find any solution. none of them work for me. unity 2022.3.10f , 2022.3.8f, 2020.3.21f. I deleted all plugins, ExternalDependencyManager, GoogleMobileAds, GooglePlayPlugins folders then updated them but it is keep crashing. then I unchecked "Auto Graphics API" in the Player settings. it is working. thanks to james580.

    but keep crashing on Android 13 (SDK 33), Android 12 (SDK 31), Android 14 Beta (SDK 34).
     
    Last edited: Oct 5, 2023