Hi!
I’m trying to implements mopub in my Android app, I followed all the guide but the ads isn’t loading.
private MoPubInterstitial mInterstitial;
private SdkInitializationListener initSdkListener() {
return new SdkInitializationListener() {
@Override
public void onInitializationFinished() {
/* MoPub SDK initialized.
Check if you should show the consent dialog here, and make your ad requests. */
}
};
}
onCreate():
SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder("407fc934d77643aa9af098f7a7bfa9ae").build();
MoPub.initializeSdk(this, sdkConfiguration, initSdkListener());
mInterstitial = new MoPubInterstitial(MainActivity.this, "407fc934d77643aa9af098f7a7bfa9ae");
mInterstitial.setInterstitialAdListener(MainActivity.this);
mInterstitial.load();
show method:
if (mInterstitial.isReady()) {
mInterstitial.show();
}
else {
Toast.makeText(MainActivity.this, "not load", Toast.LENGTH_SHORT).show();
}
interstitial methods:
@Override
public void onInterstitialLoaded(MoPubInterstitial interstitial) {
}
@Override
public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {
}
@Override
public void onInterstitialShown(MoPubInterstitial interstitial) {
}
@Override
public void onInterstitialClicked(MoPubInterstitial interstitial) {
}
@Override
public void onInterstitialDismissed(MoPubInterstitial interstitial) {
}
build.gradle(app):
allprojects {
repositories{
jcenter()
flatDir{
dirs 'libs'
}
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.exoplayer:exoplayer:r2.5.2'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation (name:'unity-ads' , ext:'aar')
implementation 'com.google.android.gms:play-services-ads:17.0.0'
implementation('com.mopub:mopub-sdk:5.4.0@aar') {
transitive = true
}
implementation('com.mopub:mopub-sdk-interstitial:5.4.0@aar') {
transitive = true
}
}
Android manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
inside aplication:
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
activities added:
<activity android:name="com.mopub.common.privacy.ConsentDialogActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<!-- All ad formats -->
<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
<!-- Interstitials -->
<activity android:name="com.mopub.mobileads.MoPubActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<!-- Rewarded Video and Rewarded Playables -->
<activity android:name="com.mopub.mobileads.RewardedMraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
I’m using only the interstitial ads. I made something wrong?