ifmvo / TogetherAd

🔥持续更新。Android广告聚合:帮助 Android 开发者快速、便捷、灵活的接入国内多家主流安卓广告 SDK。广点通(优量汇)、穿山甲、快手联盟、百青藤(百度Mob)。开屏广告、Banner横幅广告、插屏广告、激励广告、原生信息流、全屏广告。
MIT License
806 stars 174 forks source link

5.0.0及以上版本播放激励视频广告出现同时请求两个广告 #35

Closed sdfwds4 closed 3 years ago

sdfwds4 commented 3 years ago

Bug 描述和日志 5.0.0及以上版本,播放激励视频广告出现同时请求两个广告,我这边已经排除调用两次的可能。 必现的,5.0.0及以上版本才出现的。

2021-04-23 18:28:35.452 20962-21183/com.xxxx.www I/Adreno: QUALCOMM build : 6c0fbe4, I4f6179b11f Build Date : 03/05/20 OpenGL ES Shader Compiler Version: EV031.26.03.02 Local Branch : Remote Branch : refs/tags/AU_LINUX_ANDROID_LA.UM.7.11.R1.09.00.00.542.027 Remote Branch : NONE Reconstruct Branch : NOTHING 2021-04-23 18:28:35.452 20962-21183/com.xxxx.www I/Adreno: Build Config : S P 6.0.9 AArch32 2021-04-23 18:28:35.475 20962-21183/com.xxxx.www I/Adreno: PFP: 0x016ee183, ME: 0x00000000 2021-04-23 18:28:59.255 20962-20962/com.xxxx.www D/MainActivity: appPlayRewardAd: {"type_ad":5,"type":1} 2021-04-23 18:28:59.570 20962-20962/com.xxxx.www V/TogetherAd: 开始倒计时:5000 2021-04-23 18:28:59.589 20962-20962/com.xxxx.www I/TogetherAd: 提供商权重:gdt:1000,csj:4000,baidu:0, 2021-04-23 18:28:59.615 20962-20962/com.xxxx.www I/TogetherAd: 随机到的广告: csj 2021-04-23 18:28:59.765 20962-20962/com.xxxx.www V/TogetherAd: 倒计时:4806 2021-04-23 18:28:59.765 20962-20962/com.xxxx.www I/TogetherAd: csj: 开始请求 2021-04-23 18:28:59.766 20962-20962/com.xxxx.www I/RewardActivity: onAdStartRequest: csj 2021-04-23 18:29:00.523 20962-20962/com.xxxx.www I/TogetherAd: csj: 请求成功了 2021-04-23 18:29:00.524 20962-20962/com.xxxx.www I/RewardActivity: onAdLoaded: csj 2021-04-23 18:29:01.458 20962-20962/com.xxxx.www V/TogetherAd: 开始倒计时:5000 2021-04-23 18:29:01.459 20962-20962/com.xxxx.www I/TogetherAd: 提供商权重:gdt:1000,csj:4000,baidu:0, 2021-04-23 18:29:01.459 20962-20962/com.xxxx.www I/TogetherAd: 随机到的广告: csj 2021-04-23 18:29:01.647 20962-20962/com.xxxx.www V/TogetherAd: 倒计时:4811 2021-04-23 18:29:01.647 20962-20962/com.xxxx.www I/TogetherAd: csj: 开始请求 2021-04-23 18:29:01.647 20962-20962/com.xxxx.www I/RewardActivity: onAdStartRequest: csj 2021-04-23 18:29:01.684 20962-20962/com.xxxx.www I/TogetherAd: csj: 视频已缓存 2021-04-23 18:29:01.684 20962-20962/com.xxxx.www I/RewardActivity: onAdVideoCached: csj 2021-04-23 18:29:02.488 20962-20962/com.xxxx.www I/AdEvent: pangolin ad show show_3 312bfa952f6c9931a934da403b9c4d9e7e265d8eaa82ec108S6yMqPjXruZWEp/1DqzUIA0o2GYK7u+KqIP/oneBDot3tfU76PLle+JQPr0/OupktcCGW1GCFRof T1Dhzt7Cnk17yyVfTc8xD4+jH5cWVC1QT21a/CWoh0DCxgpRDcKboKy//S0pm75ADw/flxmr4uzX EwQnzxODHegMRV7nNSSurlp5d9VtEy7qsM2CqGo0HBLcxcaJ4z1boBK6dPjwNQ== 2021-04-23 18:29:02.536 20962-20962/com.xxxx.www I/TogetherAd: csj: 展示了 2021-04-23 18:29:02.537 20962-20962/com.xxxx.www I/RewardActivity: onAdShow: csj 2021-04-23 18:29:02.537 20962-20962/com.xxxx.www I/TogetherAd: csj: 曝光了 2021-04-23 18:29:02.537 20962-20962/com.xxxx.www I/RewardActivity: onAdExpose: csj 2021-04-23 18:29:02.778 20962-20962/com.xxxx.www V/TogetherAd: 倒计时:3680 2021-04-23 18:29:02.877 20962-20962/com.xxxx.www I/TogetherAd: csj: 请求成功了 2021-04-23 18:29:02.877 20962-20962/com.xxxx.www I/RewardActivity: onAdLoaded: csj 2021-04-23 18:29:03.740 20962-20962/com.xxxx.www I/AdEvent: pangolin ad show show_3 348d58524252ab670adea17486adf280255e73f8d31bb3545IuQWp4ChapjOBdIA8KSwACGM/bwLYrVCfO7RLtAPQFuZCS58D6q9tzF06Ddc6FT4pUPAHpWRfgYp Cv8CWFCaa1HeA+0mWak6e5PaXbMJnGHJwtZd2mO4BjSaTHw/CN9TjaqUfW5orLB+pdYXqucofNzb 7TbZQ2XFVfFvMOAZLcRi8id35mLDNrnUmx336J7J4r1YUjveW7KE8s21XPwSgw== 2021-04-23 18:29:03.798 20962-20962/com.xxxx.www I/TogetherAd: csj: 展示了 2021-04-23 18:29:03.799 20962-20962/com.xxxx.www I/RewardActivity: onAdShow: csj 2021-04-23 18:29:03.799 20962-20962/com.xxxx.www I/TogetherAd: csj: 曝光了 2021-04-23 18:29:03.799 20962-20962/com.xxxx.www I/RewardActivity: onAdExpose: csj 2021-04-23 18:29:03.808 20962-20962/com.xxxx.www I/TogetherAd: csj: 视频已缓存 2021-04-23 18:29:03.808 20962-20962/com.xxxx.www I/RewardActivity: onAdVideoCached: csj 2021-04-23 18:29:07.510 20962-20962/com.xxxx.www I/TogetherAd: csj: 激励验证 2021-04-23 18:29:07.510 20962-20962/com.xxxx.www I/RewardActivity: onAdRewardVerify,csj 2021-04-23 18:29:28.810 20962-20962/com.xxxx.www I/TogetherAd: csj: 激励验证 2021-04-23 18:29:28.811 20962-20962/com.xxxx.www I/RewardActivity: onAdRewardVerify,csj 2021-04-23 18:29:31.389 20962-20962/com.xxxx.www I/TogetherAd: csj: 播放完成 2021-04-23 18:29:31.389 20962-20962/com.xxxx.www I/RewardActivity: onAdVideoComplete: csj 2021-04-23 18:34:41.164 20962-20962/com.xxxx.www I/TogetherAd: csj: 关闭了 2021-04-23 18:34:41.164 20962-20962/com.xxxx.www I/RewardActivity: onAdClose: csj 2021-04-23 18:34:42.746 20962-20962/com.xxxx.www I/TogetherAd: csj: 关闭了 2021-04-23 18:34:42.747 20962-20962/com.xxxx.www I/RewardActivity: onAdClose: csj

Bug 复现的步骤 代码主要来自https://github.com/ifmvo/TogetherAd/blob/master/demo/src/main/java/com/ifmvo/togetherad/demo/reward/RewardActivity.kt

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import com.ifmvo.togetherad.core.helper.AdHelperReward
import com.ifmvo.togetherad.core.listener.RewardListener
import com.ifmvo.togetherad.core.utils.loge
import com.ifmvo.togetherad.core.utils.logi
import java.util.*
import kotlin.concurrent.timerTask

/**
 * 激励广告使用实例
 *
 * Created by Matthew Chen on 2020-04-22.
 */
class RewardActivity : Activity() {

    private val TAG = "RewardActivity"

    private lateinit var adHelperReward: AdHelperReward

    companion object {
        fun action(context: Context) {
            context.startActivity(Intent(context, RewardActivity::class.java))
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val thisActivity = this
        val rewardType = intent.getStringExtra("type")

        /**
         * activity: 必传。
         * alias: 必传。广告位的别名。初始化的时候是根据别名设置的广告ID,所以这里TogetherAd会根据别名查找对应的广告位ID。
         * ratioMap: 非必传。广告商的权重。可以不传或传null,空的情况 TogetherAd 会自动使用初始化时 TogetherAd.setPublicProviderRadio 设置的全局通用权重。
         * listener: 非必传。如果你不需要监听结果可以不传或传空。各个回调方法也可以选择性添加
         */
        adHelperReward = AdHelperReward(activity = this, alias = "ad_reward", /*ratioMap = ratioMapReward,*/ listener = object : RewardListener {
            override fun onAdStartRequest(providerType: String) {
                //在开始请求之前会回调此方法,失败切换的情况会回调多次
                addLog("\n开始请求: $providerType")
                "onAdStartRequest: $providerType".logi(TAG)
            }

            override fun onAdFailed(providerType: String, failedMsg: String?) {
                //请求失败的回调,失败切换的情况会回调多次
                addLog("请求失败: $providerType")
                "onAdFailed: $providerType: $failedMsg".loge(TAG)
                //提示一下错误,方便找bug
                Toast.makeText(thisActivity, "$providerType:$failedMsg", Toast.LENGTH_SHORT).show()
            }

            override fun onAdFailedAll(failedMsg: String?) {
                //所有配置的广告商都请求失败了,只有在全部失败之后会回调一次
                addLog("全部失败: $failedMsg")
                "onAdFailedAll: $failedMsg".loge(TAG)
                val timer = Timer()
                timer.schedule(timerTask { sendResult("error"); finish() }, 300)
            }

            override fun onAdClicked(providerType: String) {
                //点击广告的回调
                addLog("点击了: $providerType")
                "onAdClicked: $providerType".logi(TAG)
            }

            override fun onAdShow(providerType: String) {
                //广告展示展示的回调
                addLog("展示了: $providerType")
                "onAdShow: $providerType".logi(TAG)
            }

            override fun onAdLoaded(providerType: String) {
                //广告请求成功的回调,每次请求只回调一次
                addLog("请求到了: $providerType")
                "onAdLoaded: $providerType".logi(TAG)
                //onAdLoaded 回调之后才能展示
                adHelperReward.show()
            }

            override fun onAdExpose(providerType: String) {
                //广告展示曝光的回调
                addLog("曝光了: $providerType")
                "onAdExpose: $providerType".logi(TAG)
            }

            override fun onAdVideoComplete(providerType: String) {
                //视频播放完成的回调
                addLog("视频播放完成: $providerType")
                "onAdVideoComplete: $providerType".logi(TAG)
            }

            override fun onAdVideoCached(providerType: String) {
                //视频缓存完成的回调
                addLog("视频已缓存: $providerType")
                "onAdVideoCached: $providerType".logi(TAG)
            }

            override fun onAdRewardVerify(providerType: String) {
                //激励结果验证成功的回调
                addLog("激励验证,$providerType")
                "onAdRewardVerify,$providerType".logi(TAG)

                //把数据返回至上一级activity
                sendResult(rewardType)
            }

            override fun onAdClose(providerType: String) {
                //广告被关闭的回调
                addLog("关闭了: $providerType")
                "onAdClose: $providerType".logi(TAG)

                finish()
            }
        })

        //开始请求广告
        adHelperReward.load();
    }

    private fun addLog(content: String?) {
        Log.d(TAG, "addLog: " + content)
    }

    //把数据返回至上一级activity
    private fun sendResult(content: String?) {
        val data = Intent()
        data.putExtra("name", "RewardActivity")
        data.putExtra("type", content)
        setResult(Activity.RESULT_OK, data)
    }
}

截图 如果Bug展示较为明显,最好附上截图

系统版本以及设备型号

附加信息

ifmvo commented 3 years ago

2021-04-23 18:28:59.570 20962-20962/com.xxxx.www V/TogetherAd: 开始倒计时:5000 2021-04-23 18:28:59.589 20962-20962/com.xxxx.www I/TogetherAd: 提供商权重:gdt:1000,csj:4000,baidu:0, 2021-04-23 18:28:59.615 20962-20962/com.xxxx.www I/TogetherAd: 随机到的广告: csj 2021-04-23 18:28:59.765 20962-20962/com.xxxx.www V/TogetherAd: 倒计时:4806 2021-04-23 18:28:59.765 20962-20962/com.xxxx.www I/TogetherAd: csj: 开始请求 2021-04-23 18:29:00.523 20962-20962/com.xxxx.www I/TogetherAd: csj: 请求成功了 2021-04-23 18:29:01.458 20962-20962/com.xxxx.www V/TogetherAd: 开始倒计时:5000 2021-04-23 18:29:01.459 20962-20962/com.xxxx.www I/TogetherAd: 提供商权重:gdt:1000,csj:4000,baidu:0, 2021-04-23 18:29:01.459 20962-20962/com.xxxx.www I/TogetherAd: 随机到的广告: csj 2021-04-23 18:29:01.647 20962-20962/com.xxxx.www V/TogetherAd: 倒计时:4811 2021-04-23 18:29:01.647 20962-20962/com.xxxx.www I/TogetherAd: csj: 开始请求 2021-04-23 18:29:01.684 20962-20962/com.xxxx.www I/TogetherAd: csj: 视频已缓存 2021-04-23 18:29:02.536 20962-20962/com.xxxx.www I/TogetherAd: csj: 展示了 2021-04-23 18:29:02.537 20962-20962/com.xxxx.www I/TogetherAd: csj: 曝光了 2021-04-23 18:29:02.778 20962-20962/com.xxxx.www V/TogetherAd: 倒计时:3680 2021-04-23 18:29:02.877 20962-20962/com.xxxx.www I/TogetherAd: csj: 请求成功了 2021-04-23 18:29:03.798 20962-20962/com.xxxx.www I/TogetherAd: csj: 展示了 2021-04-23 18:29:03.799 20962-20962/com.xxxx.www I/TogetherAd: csj: 曝光了 2021-04-23 18:29:03.808 20962-20962/com.xxxx.www I/TogetherAd: csj: 视频已缓存 2021-04-23 18:29:07.510 20962-20962/com.xxxx.www I/TogetherAd: csj: 激励验证 2021-04-23 18:29:28.810 20962-20962/com.xxxx.www I/TogetherAd: csj: 激励验证 2021-04-23 18:29:31.389 20962-20962/com.xxxx.www I/TogetherAd: csj: 播放完成 2021-04-23 18:34:41.164 20962-20962/com.xxxx.www I/TogetherAd: csj: 关闭了 2021-04-23 18:34:42.746 20962-20962/com.xxxx.www I/TogetherAd: csj: 关闭了

把无关日志去掉,可以看到,在第一次请求成功后,进行了第二次请求,所以还需排查自身代码,看下是否重复请求