i try to create libraries for Facebook Audience Interstitial Ads with this code
interstitialAd.loadAd work fine and send request but when call interstitialAd.show i get this error
B4X:
package b4a.facebookaudi;
import com.facebook.ads.*;
import android.R;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.DontInheritEvents;
import anywheresoftware.b4a.BA.Events;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.objects.ViewWrapper;
@SuppressWarnings("unused")
@Version(1.0f)
@ShortName("FaceBookAudi")
@Events(values={"adLoaded", "IntAdError (ErrorCode As String)",
"AdScreenDismissed", "error"})
@ActivityObject
@DontInheritEvents
@Permissions(values={"android.permission.INTERNET", "android.permission.ACCESS_NETWORK_STATE"})
@DependsOn(values={"AudienceNetwork.aar","DebugSettings.aar","com.android.support:support-v4"}) //
public class FacebookAudi extends ViewWrapper<AdView> {
private InterstitialAd interstitialAd;
private String eventName;
private BA ba;
private AdView adView;
public static Object SIZE_320 = AdSize.BANNER_320_50;
public static Object SIZE_H50 = AdSize.BANNER_HEIGHT_50;
public static Object SIZE_H90 = AdSize.BANNER_HEIGHT_90;
public static Object SIZE_RH250 = AdSize.RECTANGLE_HEIGHT_250;
public void InterstitialAd(final BA ba,String PublisherId,String EventName) {
this.ba = ba;
eventName = EventName.toLowerCase(BA.cul);
interstitialAd = new InterstitialAd(ba.context, PublisherId);
interstitialAd.setAdListener(new InterstitialAdListener() {
@Override
public void onInterstitialDisplayed(Ad ad) {
// Interstitial displayed callback
}
@Override
public void onInterstitialDismissed(Ad ad) {
// Interstitial dismissed callback
}
@Override
public void onError(Ad ad, AdError adError) {
// Ad error callback
//Toast.makeText(MainActivity.this, "Error: " + adError.getErrorMessage(),
//Toast.LENGTH_LONG).show();
}
@Override
public void onAdLoaded(Ad ad) {
// Show the ad when it's done loading.
ba.raiseEvent(this, eventName + "_adLoaded");
interstitialAd.show();
}
@Override
public void onAdClicked(Ad ad) {
// Ad clicked callback
}
@Override
public void onLoggingImpression(Ad ad) {
// Ad impression logged callback
}
});
// For auto play video ads, it's recommended to load the ad
// at least 30 seconds before it is shown
interstitialAd.loadAd();
}
interstitialAd.loadAd work fine and send request but when call interstitialAd.show i get this error
B4X:
java.lang.NoClassDefFoundError: com.facebook.ads.internal.view.b.e
at com.facebook.ads.internal.view.b.d.a(Unknown Source)
at com.facebook.ads.internal.view.b.d.<init>(Unknown Source)
at com.facebook.ads.internal.view.b.b.<init>(Unknown Source)
at com.facebook.ads.internal.view.o.<init>(Unknown Source)
at com.facebook.ads.internal.view.n.<init>(Unknown Source)
at com.facebook.ads.internal.adapters.l$3.a(Unknown Source)
at com.facebook.ads.internal.adapters.l$3.a(Unknown Source)
at com.facebook.ads.internal.c.b$1$2.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5551)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)