我对Facebook Audience网络中介存在疑问。当我将其更改为最新版本(实现'com.facebook.android:audience-network-sdk:5.1.0'和实现'com.google.ads.mediation:facebook:5.1.0.0')时,我的应用程序崩溃了关闭非页内广告。但是当我离线时,我的应用程序可以正常工作。似乎是什么问题?谢谢您的回答。
这是logcat(错误):
2018-12-18 17:57:33.115 186-186/? E/BufferQueueCore:
[com.packagename.myapp/com.facebook.ads.AudienceNetworkActivity]
setDefaultMaxBufferCount: setting count to 3, previous is 2
2018-12-18 17:57:35.317 1605-1605/? E/Zygote: no v2
2018-12-18 17:57:35.327 186-186/? E/BufferQueueCore:
[com.sec.android.app.launcher/com.android.launcher2.Launcher]
setDefaultMaxBufferCount: setting count to 3, previous is 2
2018-12-18 17:57:36.418 1605-1605/? E/CII: IMSUtility:
isIMSServiceEnabled. VoLTE CSC feature disabled.
2018-12-18 17:57:36.789 1605-1634/? E/Mms/DbUtils: rebuild done, 0
drafts,Elapsed time : 26.428225 ms
2018-12-18 17:57:36.859 1635-1635/? E/Zygote: no v2
2018-12-18 17:57:36.959 1635-1635/? E/ActivityThread: Failed to find
provider info for com.samsung.android.coreapps.easysignup.public
2018-12-18 17:57:36.959 1635-1635/? E/ActivityThread: Failed to find
provider info for com.samsung.android.coreapps.easysignup.public
2018-12-18 17:57:36.959 1635-1635/? E/ActivityThread: Failed to find
provider info for com.samsung.android.coreapps.easysignup.public
2018-12-18 17:57:36.969 1635-1635/? E/ActivityThread: Failed to find
provider info for com.samsung.android.coreapps.easysignup.public
2018-12-18 17:57:36.969 1635-1635/? E/ActivityThread: Failed to find
provider info for com.samsung.android.coreapps.easysignup.public
2018-12-18 17:57:36.999 1635-1635/? E/CII: IMSUtility:
isIMSServiceEnabled. VoLTE CSC feature disabled.
2018-12-18 17:57:44.316 1414-1975/? E/Watchdog: !@Sync 2099 [12-18
17:57:44.320]
2018-12-18 17:57:51.003 210-1672/? E/NetlinkEvent:
NetlinkEvent::FindParam(): Parameter 'LABEL' not found
2018-12-18 17:57:51.003 210-1672/? E/NetlinkEvent:
NetlinkEvent::FindParam(): Parameter 'UID' not found
2018-12-18 17:57:59.781 210-1672/? E/NetlinkEvent:
NetlinkEvent::FindParam(): Parameter 'LABEL' not found
2018-12-18 17:57:59.781 210-1672/? E/NetlinkEvent:
NetlinkEvent::FindParam(): Parameter 'UID' not found
2018-12-18 17:58:06.167 1794-1794/? E/SignalClusterView:
setSlotFocusVisible : subId 5
2018-12-18 17:58:06.167 1794-1794/? E/SignalClusterView:
setSlotFocusVisible : subId 5
018-12-18 16:20:44.098 1414-1975/? E/Watchdog: !@Sync
1905 [12-18 16:20:44.109]
2018-12-18 16:20:49.363 210-1672/? E/NetlinkEvent:
NetlinkEvent::FindParam(): Parameter 'LABEL' not found
2 018-12-18 16:20:49.363 210-1672/? E/NetlinkEvent:
NetlinkEvent::FindParam(): Parameter 'UID' not found
这是我的MainActivity:
public class MainActivity extends AppCompatActivity {
private ActivityMainBinding mBinding;
private com.facebook.ads.InterstitialAd interstitialAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
interstitialAd = new com.facebook.ads.InterstitialAd(this, "FACEBOOK_ID");
interstitialAd.setAdListener(new InterstitialAdListener() {
@Override
public void onInterstitialDisplayed(Ad ad) {
}
@Override
public void onInterstitialDismissed(Ad ad) {
startActivity(new Intent(MainActivity.this, SecondActivity.class));
}
@Override
public void onError(Ad ad, AdError adError) {
}
@Override
public void onAdLoaded(Ad ad) {
}
@Override
public void onAdClicked(Ad ad) {
}
@Override
public void onLoggingImpression(Ad ad) {
}
});
interstitialAd.loadAd();
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
}
public void load(View view){
animateButtonWidth();
fadeOutTextAndSetProgressDialog();
nextAction();
}
private void animateButtonWidth(){
ValueAnimator anim = ValueAnimator.ofInt(mBinding.mainbtn.getMeasuredWidth(),getFinalWidth());
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int value = (Integer) animation.getAnimatedValue();
ViewGroup.LayoutParams layoutParams = mBinding.mainbtn.getLayoutParams();
layoutParams.width = value;
mBinding.mainbtn.requestLayout();
}
});
anim.setDuration(250);
anim.start();
}
private void fadeOutTextAndSetProgressDialog(){
mBinding.maintext.animate().alpha(0f).setDuration(250).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
showProgressDialog();
}
}).start();
}
private void showProgressDialog(){
mBinding.progressBar.getIndeterminateDrawable().setColorFilter(Color.parseColor("#FFFFFF"), PorterDuff.Mode.SRC_IN);
mBinding.progressBar.setVisibility(View.VISIBLE);
}
private void nextAction(){
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
revealButton();
fadeOutProgressDialog();
delayedStartNextActivity();
}
},4000);
}
private void revealButton(){
mBinding.mainbtn.setElevation(0f);
mBinding.revealView.setVisibility(View.VISIBLE);
int x = mBinding.revealView.getWidth();
int y = mBinding.revealView.getHeight();
int startX = (int) (getFinalWidth() / 2 + mBinding.mainbtn.getX());
int startY = (int) (getFinalWidth() / 2 + mBinding.mainbtn.getY());
float radius = Math.max(x,y) * 1.2f;
Animator reveal = ViewAnimationUtils.createCircularReveal(mBinding.revealView,startX,startY,getFinalWidth(),radius);
reveal.setDuration(350);
reveal.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
finish();
}
});
reveal.start();
}
private void fadeOutProgressDialog(){
mBinding.progressBar.animate().alpha(0f).setDuration(200).start();
}
private void delayedStartNextActivity() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (interstitialAd != null && interstitialAd.isAdLoaded()) {
interstitialAd.show();
} else {
startActivity(new Intent(MainActivity.this, SecondActivity.class));
}
}
},100);
}
private int getFinalWidth(){
return (int) getResources().getDimension(R.dimen.get_width);
}
@Override
protected void onDestroy() {
if (interstitialAd != null) {
interstitialAd.destroy();
}
super.onDestroy();
}
}