android.app.PendingIntent.checkFlags Crash on Unity

439 views
Skip to first unread message

Develop Strong

unread,
Nov 16, 2022, 8:34:20 PM11/16/22
to Google Mobile Ads SDK Developers
Hi,
I'm building an app in Unity. I am using admob 7.2.0
My app started crashing. To fix the error, I need to add these lines to the gradle:

dependencies {
  implementation 'com.google.android.gms:play-services-ads:20.4.0'
 
  // For apps targeting Android 12, add WorkManager dependency.
  constraints {
   implementation('androidx.work:work-runtime:2.7.0') {
     because '''androidx.work:work-runtime:2.1.0 pulled from
    play-services-ads has a bug using PendingIntent without
    FLAG_IMMUTABLE or FLAG_MUTABLE and will fail in Apps
    targeting S+.'''
   }
  }
}
}
-------------------------------------------------- -----------------------------------------------------
Here is what to find in my mainTemplate.gradle :

// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

// Android Resolver Repos Start
([rootProject] + (rootProject.subprojects as List)).each { project ->
    project.repositories {
        def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
        maven {
            url "https://maven.google.com"
        }
        maven {
            url "https://maven.google.com/" // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
        }
        mavenLocal()
        mavenCentral()
    }
}
// Android Resolver Repos End
apply plugin: 'com.android.library'
**APPLY_PLUGINS**

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
    implementation 'androidx.lifecycle:lifecycle-common-java8:2.4.1' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12
    implementation 'androidx.lifecycle:lifecycle-process:2.4.1' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:17
    implementation 'com.google.android.gms:play-services-ads:21.3.0' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
// Android Resolver Dependencies End
**DEPS**}

// Android Resolver Exclusions Start
android {
  packagingOptions {
      exclude('/lib/armeabi/*' + '*')
      exclude('/lib/mips/*' + '*')
      exclude('/lib/mips64/*' + '*')
      exclude('/lib/x86/*' + '*')
      exclude('/lib/x86_64/*' + '*')
  }
}
// Android Resolver Exclusions End
android {
    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'

    compileOptions {
        sourceCompatibilityJavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion **MINSDKVERSION**
        targetSdkVersion **TARGETSDKVERSION**
        ndk {
            abiFilters **ABIFILTERS**
        }
        versionCode **VERSIONCODE**
        versionName '**VERSIONNAME**'
        consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }**PACKAGING_OPTIONS**
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
-------------------------------------------------- --
Tell me how to import correctly, I have not tried so much. Either Android Resolver stops working, or it's not going to.
There is very little extensive information on solving this problem specifically for Unity.

Looking forward to an answer!

Mobile Ads SDK Forum Advisor

unread,
Nov 17, 2022, 2:19:04 AM11/17/22
to jaru...@gmail.com, google-adm...@googlegroups.com

Hi,

 

Thank you for reaching out to us.

 

With regard to your concern, can you confirm if you've tried to add the WorkManager dependency in the dependencies under mainTemplate.gradle? If not yet, I would suggest to add it under the dependencies and try to build your app in your android emulator/device. If you encounter any errors upon trying this, kindly provide us privately your sample app project and steps to replicate the error, so that we can check it also in our end. You can provide the following details via Reply privately to author option or directly provide it to the link below.

 

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

 

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002gPjioQAC&entry.80707362=00157394

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

 

 

Regards,

Google Logo
Princess Pamela
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2gPjio:ref

Develop Strong

unread,
Nov 17, 2022, 8:00:22 AM11/17/22
to Google Mobile Ads SDK Developers

Hi,
Thanks for the answer !

Here is my gradle file which is generated automatically. Where should I put this line: 
implementation('androidx.work:work-runtime:2.7.0')  ?
четверг, 17 ноября 2022 г. в 09:19:04 UTC+2, mobileadssdk:
mainTemplate.gradle

Mobile Ads SDK Forum Advisor

unread,
Nov 17, 2022, 2:00:29 PM11/17/22
to jaru...@gmail.com, google-adm...@googlegroups.com
Hello,

You may add it inside the dependencies bracket. Also, you may extract your unity project into Android project, open it using Android studio, then put the WorkManager dependency like regular android project (under dependency gradle).

Regards,
Google Logo
Teejay Wennie
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2gPjio:ref
Reply all
Reply to author
Forward
0 new messages