我正在尝试通过MoPub调解Facebook受众网络,但是我没有任何本地广告设置。我只想中介横幅广告和插页式广告。 MoPub文档中没有横幅广告和插页式广告的说明,只有原生广告和原生横幅广告。
所以,我继续并简单地添加了:
implementation 'com.mopub.mediation:facebookaudiencenetwork:5.5.0.8'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.facebook.android:audience-network-sdk:5.6.0'
到我的应用程序:build.gradle 然后我在onCreate方法中初始化了Audience Network SDK。
AudienceNetworkAds.initialize(this);
然后我创建了一个HashMap:
Map<String, String> facebookConfig = new HashMap<>();
facebookConfig.put("banner", "");
facebookConfig.put("interstitial", "”);
并将哈希表传递给sdkconfiguration中介设置:
SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder("AD_UNIT_ID");
sdkConfiguration.withMediatedNetworkConfiguration(FacebookAdapterConfiguration.class.getName(), facebookConfig);
sdkConfiguration.withLegitimateInterestAllowed(false).build();
我在这里想念什么?
这是我在Studio中遇到的错误:
E/ActivityThread: Activity in.techpop.squarifymyphotos.MainActivity has leaked IntentReceiver com.mopub.mobileads.MoPubView$1@8492337 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity in.techpop.squarifymyphotos.MainActivity has leaked IntentReceiver com.mopub.mobileads.MoPubView$1@8492337 that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1588)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1368)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1515)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1488)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1476)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:627)
at com.mopub.mobileads.MoPubView.registerScreenStateBroadcastReceiver(MoPubView.java:193)
at com.mopub.mobileads.MoPubView.<init>(MoPubView.java:155)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:854)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at in.techpop.squarifymyphotos.MainActivity.onCreate(MainActivity.java:31)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1306)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
答案 0 :(得分:0)
您获得的异常仅来自MoPubView或MoPubInterstitial,而没有在活动onDestroy()方法中调用#destroy。
@Override
protected void onDestroy() {
super.onDestroy();
moPubView.destroy(); }
moPubInterstitial.destroy();
}