fbsamples / audience-network

Open source projects to demonstrate SDK and sample code usages and integration, and to collaborate and support peers in this community.
https://developers.facebook.com/docs/audience-network
Other
319 stars 370 forks source link

Crash for android version S: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. #159

Closed superdiazzz closed 2 years ago

superdiazzz commented 2 years ago

I got this issue after upgrate targetSdkVersion to 31, i use this dapendency

implementation ('com.facebook.android:audience-network-sdk:5.5.0'){
        exclude group: 'com.google.android.gms'
    }

and i initialized my apps with this snippet code in Application class

private fun defaultProcessInitialization(app: NewsApplication?) {
        if (BuildConfig.DEBUG) {
            StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
                    .detectAll()
                    .penaltyLog()
                    .build())
            StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder()
                    .detectAll()
                    .penaltyLog()
                    .build())
        }
        // Let Audience Network SDK know that you want to use Multiprocess Support
        AdSettings.setMultiprocessSupportMode(
                AdSettings.MultiprocessSupportMode.MULTIPROCESS_SUPPORT_MODE_ON)

        if(BuildConfig.DEBUG){
            AdSettings.addTestDevice("xxxxx")
        }

        AudienceNetworkAds
                .buildInitSettings(app)
                .withInitListener(app)
                .initialize()
    }
Fatal Exception: java.lang.IllegalArgumentException: mobile.android.tribun: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
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.
       at android.app.PendingIntent.checkFlags(PendingIntent.java:382)
       at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:465)
       at android.app.PendingIntent.getActivity(PendingIntent.java:451)
       at android.app.PendingIntent.getActivity(PendingIntent.java:415)
       at com.facebook.ads.redexgen.X.FF.E(FF.java:25701)
       at com.facebook.ads.redexgen.X.Fn.C(Fn.java:26419)
       at com.facebook.ads.redexgen.X.Fl.FC(Fl.java:26298)
       at com.facebook.ads.redexgen.X.Fl.PC(Fl.java:26369)
       at com.facebook.ads.redexgen.X.8E.C(8E.java:18158)
       at com.facebook.ads.redexgen.X.8E.getBidderToken(8E.java:18169)
       at com.facebook.ads.redexgen.X.FP.run(FP.java:25949)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:920)

Somebody, Please help me

github-actions[bot] commented 2 years ago

Dear developers. You will not be able to create new bug reports on GitHub after 28 April, and existing tickets will be automatically closed.

Instead, please use the bug report (https://developers.facebook.com/support/bugs/) tool to report a bug on Audience Network. Our engineers will get back to you as soon as possible.

If you have any other questions or suggestions relating to Facebook Audience Network, please use the online publisher support portal (https://www.facebook.com/business/publishersupport?hc_location=ufi) to submit a request.