当前位置: 首页 > 知识库问答 >
问题:

FacebookAds:定位 S(版本 31 及以上)要求在创建“待处理”时指定FLAG_IMMUTABLE之一或FLAG_MUTABLE

蓟雪峰
2023-03-14

我正在使用Facebook Audience Network通过该应用程序获利,但最近在将targetSdkVersion升级到31后,我在crashlytics中遇到了巨大的问题,我使用此依赖项

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

我用这个代码片段代码初始化了我的应用程序 在创建应用程序类

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()
    }

但问题只出现在AndroidS中

这是日志报告:

Fatal Exception: java.lang.IllegalArgumentException: mobile.android.myapp: 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)

请有人帮帮我

共有1个答案

堵鸿光
2023-03-14

com.facebook.android:audio network sdk:5.5.0于2019年8月推出,远远落后于目前的6.8.0版本。特别是,2019年8月,Android 12即将上市。

最终,您需要升级到最新版本,然后希望Facebook将该标志添加到PendingIntent

或者,您可以暂时将targetSdkVersion降低到30。

 类似资料: