首页 > 解决方案 > 插页式广告和再创作活动

问题描述

我有一个 Admob 插页式广告:

fun showInterstitialAd()
    {
        if (mInterstitialAd != null) {
            mInterstitialAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
                override fun onAdDismissedFullScreenContent() {
                    Log.d("Ad message", "Ad was dismissed.")
                    mInterstitialAd = null
                    loadInterstitialAd()
                }

                override fun onAdFailedToShowFullScreenContent(adError: AdError?) {
                    Log.d("Ad message", "Ad failed to show. ${adError?.message}")
                    mInterstitialAd = null
                }
            }
            mInterstitialAd?.show(this)
        } else {
            Log.d("Ad message", "The interstitial ad wasn't ready yet.")
        }
    }

    private fun loadInterstitialAd()
    {
        val adRequest = AdRequest.Builder().build()

        InterstitialAd.load(this, "ca-app-pub-3940256099942544/1033173712",
            adRequest,
            object : InterstitialAdLoadCallback() {
                override fun onAdFailedToLoad(adError: LoadAdError) {
                    Log.d("Ad message", adError.message)
                    mInterstitialAd = null
                }

                override fun onAdLoaded(interstitialAd: InterstitialAd) {
                    Log.d("Ad message", "Ad was loaded.")
                    mInterstitialAd = interstitialAd
                }
            })

    }

该广告是由调用 MainActivity.getInstance().showInterstitialAd() 的片段触发的,并且在某些时候我更改了应用程序的主题,从而触发了活动的重新创建。片刻之后,应用程序因线程池异常而崩溃:

    2021-09-20 16:24:01.270 10215-10041/? A/google-breakpad: -----BEGIN BREAKPAD MICRODUMP-----
2021-09-20 16:24:01.270 10215-10041/? A/google-breakpad: V WebView:51.0.2704.90
2021-09-20 16:24:01.270 10215-10041/? A/google-breakpad: O A x86 04 i686 google/sdk_google_phone_x86/generic_x86:7.0/NYC/4409132:user/release-keys
2021-09-20 16:24:01.270 10215-10041/? A/google-breakpad: G OpenGL ES 2.0 (4.5.0 NVIDIA 457.63)|Google (NVIDIA Corporation)|Android Emulator OpenGL ES Translator (GeForce GTX 1660 Ti/PCIe/SSE2)
2021-09-20 16:24:01.270 10215-10041/? A/google-breakpad: S 0 BFAFAC64 BFAFA000 00004000
2021-09-20 16:24:01.273 10215-10041/? A/google-breakpad: S BFAFA000 88A1AFBF6CBBF7AD38A0AFBF9101D9AD88A1AFBF01000000F44C71B90461C27140C105AE6B0D9DAD98A0AFBF28A1AFBF88A1AFBF6CBBF7AD68A1AFBFBF25D7AD88A1AFBF0000000068A0AFBF88E9F7AD00405D7104216500F44C71B970E2190100B001AE04A1B9AF88A0AFBFE8A1AFBF0000000088E9F7AD8CB400AE52A7B1AD00A1AFBF6CBBF7AD00000000E8A1AFBF88A1AFBF6CBBF7ADC8A1AFBFBF25D7ADE8A1AFBF0000000068A1AFBF2FB098AD10A1AFBF10A1AFBF0000000077BCEDADE8A0AFBF643000AE04B001AEA30A16AE0000000088E9F7AD8CB400AED60AEEAD000B5D86600B5D8600000000B04719AE04B001AE743000AE80095D8603E295AD99CDEDAD140000000000000001E219AE00B400AE301202AEC00003AE00B400AE4300000043000000000402AE7113B1AD301202AE806045A2B4A2AFBF80095D86600B5D866CBBF7ADF44C71B96105B1AD50B2D8126CBBF7ADA8A1AFBF0000000088A1AFBF6CBBF7ADE8A1AFBF9541D8AD88A1AFBF000000000000000000000000
.
.
.
2021-09-20 16:24:01.286 10215-10041/? A/google-breakpad: M B2263000 00000000 000CB000 413A040187E1467E67CE4167BEA2F7E30 linker
2021-09-20 16:24:01.286 10215-10041/? A/google-breakpad: -----END BREAKPAD MICRODUMP-----
2021-09-20 16:24:01.299 10041-10041/com.myapp A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 10041 (.myapp)
2021-09-20 16:24:01.301 22029-10153/? E/AsyncOperation: operation=xlb, opStatusCode=12009 [CONTEXT service_id=45 ]
    OperationException[Status{statusCode=unknown status code: 12009, resolution=null}]
        at azpc.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):1)
        at azpc.f(:com.google.android.gms@213314022@21.33.14 (040700-395723304):49)
        at afcb.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):17)
        at bywp.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):2)
        at wuw.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):6)
        at wuw.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):7)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at xav.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):0)
        at java.lang.Thread.run(Thread.java:761)
2021-09-20 16:24:01.302 22029-10153/? E/AsyncOperation: operation=xlb, opStatusCode=12009 [CONTEXT service_id=45 ]
    OperationException[Status{statusCode=unknown status code: 12009, resolution=null}]
        at azpc.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):1)
        at azpc.f(:com.google.android.gms@213314022@21.33.14 (040700-395723304):49)
        at afcb.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):17)
        at bywp.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):2)
        at wuw.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):6)
        at wuw.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):8)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at xav.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):0)
        at java.lang.Thread.run(Thread.java:761)
2021-09-20 16:24:01.302 22029-10153/? E/AsyncOperation: operation=xlb, opStatusCode=12009 [CONTEXT service_id=45 ]
    OperationException[Status{statusCode=unknown status code: 12009, resolution=null}]
        at azpc.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):1)
        at azpc.f(:com.google.android.gms@213314022@21.33.14 (040700-395723304):49)
        at afcb.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):17)
        at bywp.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):2)
        at wuw.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):6)
        at wuw.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):8)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at xav.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):0)
        at java.lang.Thread.run(Thread.java:761)
2021-09-20 16:24:01.302 22029-10153/? E/AsyncOperation: operation=xlb, opStatusCode=12009 [CONTEXT service_id=45 ]
    OperationException[Status{statusCode=unknown status code: 12009, resolution=null}]
        at azpc.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):1)
        at azpc.f(:com.google.android.gms@213314022@21.33.14 (040700-395723304):49)
        at afcb.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):17)
        at bywp.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):2)
        at wuw.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):6)
        at wuw.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):8)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at xav.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):0)
        at java.lang.Thread.run(Thread.java:761)
2021-09-20 16:24:01.303 22029-10153/? E/AsyncOperation: operation=xlb, opStatusCode=12009 [CONTEXT service_id=45 ]
    OperationException[Status{statusCode=unknown status code: 12009, resolution=null}]
        at azpc.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):1)
        at azpc.f(:com.google.android.gms@213314022@21.33.14 (040700-395723304):49)
        at afcb.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):17)
        at bywp.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):2)
        at wuw.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):6)
        at wuw.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):8)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at xav.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):0)
        at java.lang.Thread.run(Thread.java:761)
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG: Build fingerprint: 'google/sdk_google_phone_x86/generic_x86:7.0/NYC/4409132:user/release-keys'
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG: Revision: '0'
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG: ABI: 'x86'
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG: pid: 10041, tid: 10041, name: .myapp  >>> com.myapp <<<
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG:     eax 00000000  ebx 9e69baa8  ecx 8fa69150  edx 86bf2640
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG:     esi 1317ff20  edi 8fa6a20c
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG:     xcs 00000073  xds 0000007b  xes 0000007b  xfs 0000003b  xss 0000007b
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG:     eip 9d8141aa  ebp bfafacc8  esp bfafac64  flags 00210296
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG: backtrace:
2021-09-20 16:24:01.360 10217-10217/? A/DEBUG:     #00 pc 02d811aa  /system/app/Chrome/Chrome.apk (offset 0xc57000)
2021-09-20 16:24:01.931 22029-10153/? E/AsyncOperation: operation=xlb, opStatusCode=12009 [CONTEXT service_id=45 ]
    OperationException[Status{statusCode=unknown status code: 12009, resolution=null}]
        at azpc.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):1)
        at azpc.f(:com.google.android.gms@213314022@21.33.14 (040700-395723304):49)
        at afcb.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):17)
        at bywp.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):2)
        at wuw.c(:com.google.android.gms@213314022@21.33.14 (040700-395723304):6)
        at wuw.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):7)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at xav.run(:com.google.android.gms@213314022@21.33.14 (040700-395723304):0)
        at java.lang.Thread.run(Thread.java:761)
2021-09-20 16:24:01.932 1342-1342/? E/lowmemorykiller: Error writing /proc/10041/oom_score_adj; errno=22
2021-09-20 16:24:01.996 1634-1986/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 68)
2021-09-20 16:24:02.008 1634-1682/? E/ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ id=234, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-09-20 16:24:02.010 1634-1682/? E/ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ id=235, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-09-20 16:24:02.011 1634-1682/? E/ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ id=236, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-09-20 16:24:02.260 10225-10225/? E/memtrack: Couldn't load memtrack module (No such file or directory)
2021-09-20 16:24:02.260 10225-10225/? E/android.os.Debug: failed to load memtrack module: -2

有谁知道为什么会这样?以及如何解决?我假设 InterstitialAd.load 在后台做一些工作,当活动重新创建自己时,线程有一些问题继续存在吗?

谢谢!

标签: androidadmobthreadpool

解决方案


推荐阅读