Audience Network interstitial/rewarded ad show Android crash on Unity - android

i'm trying to display Facebook ads on Android. I have included the Audience Network .jar on my Android Studio Project. Also added the activity to the Android Manifest.
This is the build.gradle:
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
testOptions {
unitTests.returnDefaultValues = true
}
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
}
debug {
debuggable true
jniDebuggable true
minifyEnabled false
shrinkResources false
}
}
}
dependencies {
// Required -- JUnit 4 framework
testCompile 'junit:junit:4.12'
// Optional -- Mockito framework
testCompile 'org.mockito:mockito-core:1.10.19'
compile 'com.google.android.gms:play-services:10.2.0'
compile files('libs/AudenceNetwork-4.24.0.jar')
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.0'
}
This is a snippet on how i load and show interstitials and rewarded:
com.facebook.ads.InterstitialAd interstitial;
com.facebook.ads.RewardedVideoAd rewarded
public void loadInterstitial() {
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
if (interstitial == null) {
interstitial = new com.facebook.ads.InterstitialAd(activity, interstitialAd.getCode());
CustomFacebookInterstitialAdListener interestitialListener = new CustomFacebookInterstitialAdListener(AudienceNetworkAdProvider.this);
interstitial.setAdListener(interestitialListener);
}
interstitial.loadAd();
}
});
}
public void showInterstitial() {
if (isInterstitialAvailable()) {
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
interstitial.show();
}
});
}
}
public void loadRewardedAd() {
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
if (rewarded == null) {
rewarded = new com.facebook.ads.RewardedVideoAd(activity, rewardedAd.getCode());
CustomFacebookRewardedAdListener rewardedListener = new CustomFacebookRewardedAdListener(AudienceNetworkAdProvider.this);
rewarded.setAdListener(rewardedListener);
}
rewarded.loadAd();
}
});
}
public void showRewardedAd() {
if (isRewardedAdAvailable()) {
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
rewarded.show();
}
});
}
}
The code works fine on a Android native test app.
I'm making an adaptation to Unity, so i can show ads on a game. However, every time i want to display an ad it randomly crashes the app. Most of the times it let me see one interstitial or rewarded, but after that crashes.
This is how my Plugins/Android folder looks like:
AndroidManifest.xml
appcompat-v7-24.0.0
myaudiencenetworkadapter.aar
play-services-10.0.1.aar
play-services-auth-10.0.1
play-services-auth-base-10.0.1
play-services-basement-10.0.1
play-services-drive-10.0.1
play-services-tasks-10.0.1
recyclerview-v7-24.0.0
support-v4-24.0.0
It crashes when com.facebook.ads.RewardedVideoAd.show() method is invoked.
This is the log of the crash:
08-07 16:51:30.861 16820-16820/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.somepackage.test, PID: 16820
java.lang.Error: FATAL EXCEPTION [main]
Unity version : 5.5.3f1
Device model : samsung SM-G925I
Device fingerprint: samsung/zeroltedv/zerolte:6.0.1/MMB29K/G925IDVS3EQF1:user/release-keys
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.facebook.ads.internal.DisplayAdController.c()' on a null object reference
at com.facebook.ads.RewardedVideoAd.show(Unknown Source)
at com.boxit.ads.facebook.AudienceNetworkAdProvider$3.run(AudienceNetworkAdProvider.java:168)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Any ideas?

You shouldn't be messing with Java and the Facebook jar in Android Studio while there is an official Unity Facebook plugin. See this link for instructions on how to set it up and here to get the actual SDK.
When you download the plugin you will find InterstitialAdScene, RewardedVideoAdScene and NativeAdScene scenes that contains sample codes for you should load InterstitialAdScene scene since that's what you are looking for.
Below is C# Interstitial Ad example from the InterstitialAdTest.cs file in the AudienceNetwork\Samples\Interstitial folder.
public class InterstitialAdTest : MonoBehaviour
{
private InterstitialAd interstitialAd;
private bool isLoaded;
// UI elements in scene
public Text statusLabel;
// Load button
public void LoadInterstitial ()
{
this.statusLabel.text = "Loading interstitial ad...";
// Create the interstitial unit with a placement ID (generate your own on the Facebook app settings).
// Use different ID for each ad placement in your app.
InterstitialAd interstitialAd = new InterstitialAd ("YOUR_PLACEMENT_ID");
this.interstitialAd = interstitialAd;
this.interstitialAd.Register (this.gameObject);
// Set delegates to get notified on changes or when the user interacts with the ad.
this.interstitialAd.InterstitialAdDidLoad = (delegate() {
Debug.Log ("Interstitial ad loaded.");
this.isLoaded = true;
this.statusLabel.text = "Ad loaded. Click show to present!";
});
interstitialAd.InterstitialAdDidFailWithError = (delegate(string error) {
Debug.Log ("Interstitial ad failed to load with error: " + error);
this.statusLabel.text = "Interstitial ad failed to load. Check console for details.";
});
interstitialAd.InterstitialAdWillLogImpression = (delegate() {
Debug.Log ("Interstitial ad logged impression.");
});
interstitialAd.InterstitialAdDidClick = (delegate() {
Debug.Log ("Interstitial ad clicked.");
});
// Initiate the request to load the ad.
this.interstitialAd.LoadAd ();
}
// Show button
public void ShowInterstitial ()
{
if (this.isLoaded) {
this.interstitialAd.Show ();
this.isLoaded = false;
this.statusLabel.text = "";
} else {
this.statusLabel.text = "Ad not loaded. Click load to request an ad.";
}
}
void OnDestroy ()
{
// Dispose of interstitial ad when the scene is destroyed
if (this.interstitialAd != null) {
this.interstitialAd.Dispose ();
}
Debug.Log ("InterstitialAdTest was destroyed!");
}
// Next button
public void NextScene ()
{
SceneManager.LoadScene ("AdViewScene");
}
}

I finally solved the issue.
I was destroying Audience Network ads on the onPause event from my Unity activity. Every time an ad is displayed, onPause event is called so it was a mess.

Related

Android - queryPurchase() returns an empty list but I purchased an in app product

I have implemented in app products in my app. I can make successful purchase and everything works fine. But in one device, purchase doesn't work although when I try to make a purchase again, I get the response "Product already owned" which shows that the purchase is fine. But queryPurchase() returns an empty purchase list.
I've only one email on that device.
public void queryPurchase() {
Runnable queryPurchaseRequest = getQueryPurchaseRequest();
executeRequest(queryPurchaseRequest);
}
private Runnable getQueryPurchaseRequest() {
return new Runnable() {
#Override
public void run() {
Purchase.PurchasesResult purchasesResult = mBillingClient.queryPurchases(BillingClient.SkuType.INAPP);
if(purchasesResult.getResponseCode() == BillingResponseCode.OK) {
ArrayList<Purchase> purchaseList = new ArrayList<>();
purchaseList.addAll(purchasesResult.getPurchasesList());
if(isSubscriptionSupported()) {
Purchase.PurchasesResult subscriptionResult
= mBillingClient.queryPurchases(BillingClient.SkuType.SUBS);
if (subscriptionResult.getResponseCode() == BillingResponseCode.OK) {
purchaseList.addAll(subscriptionResult.getPurchasesList());
} else {
Log.e(TAG, "Got an error response trying to query subscription purchases");
}
}
onQueryPurchasesFinished(purchaseList);
} else {
Utilities.setPurchaseLog("onBilling manager on query purchase request: result unknown\n");
}
}
};
}
Note: Billing result, subscription response code everything seems successful. And everything is working perfectly on other devices.
Have anyone any solution? Thanks for your help!
It is a known bug that has been happening for ages now, since billing libraries version 2.x (Priority: P1 , Severity S2)
https://issuetracker.google.com/issues/160473001
I think the best thing you can do is going there and leaving your star/comment to try to speed things up.
However, there's something we can miss sometimes: It turns out that you need to wait for the billingClient.startConnection() call to finish doing it's thing and onBillingSetupFinished() callback gets called on the provided BillingClientStateListener. Only after that you can call the queryPurchases method. If you call queryPurchases beforee finishing the connection to the service, you will get an empty list.
I got my answer to this same question via
this answer
I had to comment out the debug suffix in the .app build.gradle
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
// applicationIdSuffix ".debug"
debuggable true
}
}

How to fix NoClassDefFoundError: android.media.session.MediaSessionManager

I made an app it run perfectly in api 20+ but for android version 4.4 and less it is getting crashed with error NoClassDefFoundError: android.media.session.MediaSessionManager this is the stack trace that i am getting in the developer console .
java.lang.NoClassDefFoundError: android.media.session.MediaSessionManager
at beatbox.neelay.beatbox.MediaService.initMediaSession(MediaService.java:634)
at beatbox.neelay.beatbox.MediaService.onStartCommand(MediaService.java:170)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2913)
at android.app.ActivityThread.access$2100(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1442)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5339)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(Native Method)
All I am able to understand from this is the error is in the initMediaSession method .this is my initMediaSession method
private void initMediaSession() throws RemoteException {
if (mediaSessionManager != null) return; //mediaSessionManager exists
mediaSessionManager = (MediaSessionManager) getSystemService(Context.MEDIA_SESSION_SERVICE);
// Create a new MediaSession
mediaSession = new MediaSessionCompat(getApplicationContext(), "AudioPlayer");
//Get MediaSessions transport controls
transportControls = mediaSession.getController().getTransportControls();
//set MediaSession -> ready to receive media commands
mediaSession.setActive(true);
//indicate that the MediaSession handles transport control commands
// through its MediaSessionCompat.Callback.
mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
//Set mediaSession's MetaData
updateMetaData();
// passing the data
// Attach Callback to receive MediaSession updates
mediaSession.setCallback(new MediaSessionCompat.Callback() {
// Implement callbacks
#Override
public void onPlay() {
super.onPlay();
messagesent();
a = false;
resumeMedia();
buildNotification(PlaybackStatus.PLAYING);
}
#Override
public void onPause() {
super.onPause();
messagesent();
a = true;
pauseMedia();
buildNotification(PlaybackStatus.PAUSED);
}
#Override
public void onSkipToNext() {
super.onSkipToNext();
skipToNext();
updateMetaData();
buildNotification(PlaybackStatus.PLAYING);
}
#Override
public void onSkipToPrevious() {
super.onSkipToPrevious();
skipToPrevious();
updateMetaData();
buildNotification(PlaybackStatus.PLAYING);
}
#Override
public void onStop() {
super.onStop();
removeNotification();
//Stop the service
pauseMedia();
messagesent();
stopSelf();
}
#Override
public void onSeekTo(long position) {
super.onSeekTo(position);
}
});
}
I dont understand why it is getting crashend for 4.4 and less devices and how i can fix this .I googled and got this but this post dont tell how tofix this.
MediaSessionManager was only added in api 21 (5.0)
If it's absolutely necessary to use it then you can set your min sdk to 21 or check your build number with:
android.os.Build.VERSION.SDK
and not call this service with devices with lower sdks
It seems that the reason may be due to multidex. Check your apk method count at Get Method Count
You can enable multidex by adding dependency
compile 'com.android.support:multidex:1.0.1'
then enable it in config
defaultConfig {
multiDexEnabled true
}
add following snippet in android section of your
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries false
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex'
// this is optional
dx.additionalParameters += "--main-dex-list=$projectDir/multidex.keep".toString()
}
}
compileOptions {
incremental false
}
I am also following the same tutorial and had same issue. I found the solution to this. Simply check if your SDK >21 then only use method initMediaSession();

what is Google Play services MeasurementBrokerService and how to stop it?

I have created a Service which listens to a Firebase location.
This is a simple service with low memory usage. Unfortunately, I am seeing a Google play services service called MeasurementBrokerService joining my service and not freeing memory.
Unlike a related question :
"Service MeasurementBrokerService is in use" is showing in my application process
The above question has no accepted answer, so kindly do not mark this as a duplicate
I am not using firebase-appindexing.
Following is my app level gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.project.recommendedapp"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.github.clans:fab:1.6.4'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile('com.crashlytics.sdk.android:crashlytics:2.6.0#aar') {
transitive = true;
}
compile 'com.facebook.fresco:fresco:1.0.0'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.squareup.okhttp3:okhttp:3.5.0'
}
apply plugin: 'com.google.gms.google-services'
Can someone please guide me as to how to stop the service from joining my process.
The service is as follows:
public class SubscriptionListenerService extends Service {
DatabaseReference userNodeSubscriptionRef;
ChildEventListener subscribedTopicsListener;
SharedPreferences sessionPref,subscribedTopicsPreference;
SharedPreferences.Editor subscribedtopicsprefeditor;
String userid;
boolean stoppedInternally = false;
SharedPreferences.OnSharedPreferenceChangeListener sessionPrefChangeListener;
#Nullable
#Override
public IBinder onBind(Intent intent) {
//do not need a binder over here
return null;
}
#Override
public void onCreate(){
super.onCreate();
Log.d("FragmentCreate","onCreate called inside service");
sessionPref = getSharedPreferences("SessionPref",0);
subscribedTopicsPreference=getSharedPreferences("subscribedTopicsPreference",0);
subscribedtopicsprefeditor=subscribedTopicsPreference.edit();
userid = sessionPref.getString("userid",null);
sessionPrefChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
#Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Log.d("FragmentCreate","The shared preference changed "+key);
stoppedInternally=true;
sessionPref.unregisterOnSharedPreferenceChangeListener(this);
if(userNodeSubscriptionRef!=null && subscribedTopicsListener!=null){
userNodeSubscriptionRef.removeEventListener(subscribedTopicsListener);
}
stopSelf();
}
};
sessionPref.registerOnSharedPreferenceChangeListener(sessionPrefChangeListener);
subscribedTopicsListener = new ChildEventListener() {
#Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
if(!(dataSnapshot.getValue() instanceof Boolean)){
Log.d("FragmentCreate","Please test subscriptions with a boolean value");
}else {
if ((Boolean) dataSnapshot.getValue()) {
//here we subscribe to the topic as the topic has a true value
Log.d("FragmentCreate", "Subscribing to topic " + dataSnapshot.getKey()+" "+this.getClass().getName());
subscribedtopicsprefeditor.putBoolean(dataSnapshot.getKey(), true);
FirebaseMessaging.getInstance().subscribeToTopic(dataSnapshot.getKey());
} else {
//here we unsubscribed from the topic as the topic has a false value
Log.d("FragmentCreate", "Unsubscribing from topic " + dataSnapshot.getKey()+" "+this.getClass().getName());
subscribedtopicsprefeditor.remove(dataSnapshot.getKey());
FirebaseMessaging.getInstance().unsubscribeFromTopic(dataSnapshot.getKey());
}
subscribedtopicsprefeditor.commit();
}
}
#Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
//either an unsubscription will trigger this, or a re-subscription after an unsubscription
if(!(dataSnapshot.getValue() instanceof Boolean)){
Log.d("FragmentCreate","Please test subscriptions with a boolean value");
}else{
if((Boolean)dataSnapshot.getValue()){
Log.d("FragmentCreate","Subscribing to topic "+dataSnapshot.getKey()+" "+this.getClass().getName());
subscribedtopicsprefeditor.putBoolean(dataSnapshot.getKey(),true);
FirebaseMessaging.getInstance().subscribeToTopic(dataSnapshot.getKey());
}else{
Log.d("FragmentCreate","Unsubscribing from topic "+dataSnapshot.getKey()+" "+this.getClass().getName());
subscribedtopicsprefeditor.remove(dataSnapshot.getKey());
FirebaseMessaging.getInstance().unsubscribeFromTopic(dataSnapshot.getKey());
}
subscribedtopicsprefeditor.commit();
}
}
#Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
//Log.d("FragmentCreate","Unubscribing from topic "+dataSnapshot.getKey());
//FirebaseMessaging.getInstance().unsubscribeFromTopic(dataSnapshot.getKey());
}
#Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
//do nothing, this won't happen --- rather this isnt important
}
#Override
public void onCancelled(DatabaseError databaseError) {
Log.d("FragmentCreate","Failed to listen to subscriptions node");
}
};
if(userid!=null){
Log.d("FragmentCreate","Found user id in service "+userid);
userNodeSubscriptionRef = FirebaseDatabase.getInstance().getReference().child("Users").child(userid).child("subscriptions");
userNodeSubscriptionRef.addChildEventListener(subscribedTopicsListener);
userNodeSubscriptionRef.keepSynced(true);
}else{
Log.d("FragmentCreate","Couldn't find user id");
stoppedInternally=true;
stopSelf();
}
}
#Override
public int onStartCommand(Intent intent,int flags,int startId){
//don't need anything done over here
//The intent can have the following extras
//If the intent was started by the alarm manager ..... it will contain android.intent.extra.ALARM_COUNT
//If the intent was sent by the broadcast receiver listening for boot/update ... it will contain wakelockid
//If it was started from within the app .... it will contain no extras in the intent
//The following will not throw an exception if the intent does not have an wakelockid in extra
//As per android doc... the following method releases the wakelock if any specified inside the extra and returns true
//If no wakelockid is specified, it will return false;
if(intent!=null){
if(BootEventReceiver.completeWakefulIntent(intent)){
Log.d("FragmentCreate","Wakelock released");
}else{
Log.d("FragmentCreate","Wakelock not acquired in the first place");
}
}else{
Log.d("FragmentCreate","Intent started by regular app usage");
}
return START_STICKY;
}
#Override
public void onDestroy(){
if(userNodeSubscriptionRef!=null){
userNodeSubscriptionRef.keepSynced(false);
}
userNodeSubscriptionRef = null;
subscribedTopicsListener = null;
sessionPref = null;
subscribedTopicsPreference = null;
subscribedtopicsprefeditor = null;
userid = null;
sessionPrefChangeListener = null;
if(stoppedInternally){
Log.d("FragmentCreate","Service getting stopped due to no userid or due to logout or data clearance...do not restart auto.. it will launch when user logs in or signs up");
}else{
Log.d("FragmentCreate","Service getting killed by user explicitly from running services or by force stop ... attempt restart");
//well basically restart the service using an alarm manager ... restart after one minute
AlarmManager alarmManager = (AlarmManager) this.getSystemService(ALARM_SERVICE);
Intent restartServiceIntent = new Intent(this,SubscriptionListenerService.class);
restartServiceIntent.setPackage(this.getPackageName());
//context , uniqueid to identify the intent , actual intent , type of pending intent
PendingIntent pendingIntentToBeFired = PendingIntent.getService(this,1,restartServiceIntent,PendingIntent.FLAG_ONE_SHOT);
if(Build.VERSION.SDK_INT>=23){
alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime()+600000,pendingIntentToBeFired);
}else{
alarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime()+600000,pendingIntentToBeFired);
}
}
super.onDestroy();
}
}
I checked that somehow still google AppMeasurement service was running on my device.
I have resorted to using the following approach:
The following stops data collection by firebase.
https://firebase.google.com/support/guides/disable-analytics tells us the following approach
<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />
This alone still can't stop the appMeasurement from initializing.
The second step that has solved is adding the following to the app level gradle file:
configurations {
all*.exclude group: 'com.google.firebase', module: 'firebase-core'
}
This basically removes all the code that firebase analytics uses.
In case it still doesn't work, make sure that the gradle does not include broad play service dependency
eg: compile 'com.google.android.gms:play-services-location:10.0.1'
instead of 'com.google.android.gms:play-services:10.0.1'
Worst case and i have not tested this as the above solved it for me is:
https://developers.google.com/analytics/devguides/collection/android/v4/advanced
Google should really stop putting unwanted things without the dev's permission IMHO. Hope this helps someone

adColony Expecting libadcolony.so in libs directory but it was not found

I'm trying to implement reward video with adColony but i'm getting trouble
In folder app/libs i have added libadcolony.so also adcolony.jar version 3.0.7 in lib folder
in my activity
AdColony.configure(this, appOptions, "app83c6f9efcc25******",
"vzf20fd3c78687******");
AdColonyAdOptions options = new AdColonyAdOptions()
.enableConfirmationDialog(true)
.enableResultsDialog(true);
AdColonyRewardListener listener = new AdColonyRewardListener() {
#Override
public void onReward(AdColonyReward reward) {
/** Query the reward object for information here */
gagner3Piece();
}
};
i also try this:
/** Set reward listener for your app to be alerted of reward events */
AdColony.setRewardListener(listener);
AdColonyInterstitialListener AdColonyInterstitialListener = new
AdColonyInterstitialListener() {
#Override
public void onRequestFilled(AdColonyInterstitial
adColonyInterstitial) {
rewardAdColonyInterstitial = adColonyInterstitial;
}
};
AdColony.requestInterstitial("vzf20fd3c7868742bfaa",
AdColonyInterstitialListener, options);
I have this erros :
E/AdColony [ERROR]: Expecting libadcolony.so in libs directory but it was
not found.
I/AdColony [INFO]: Configuring AdColony
E/AdColony [ERROR]: The AdColony API is not available while AdColony is
disabled.
any help would be appreciated
I had to add
android {
/** Any other configurations here */
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}
see from here https://github.com/AdColony/AdColony-Android-SDK-3/wiki/Project-Setup

Interestial Ads Not Showing on Live Android Device for Game Build in Unity 4.6

I am using Unity Version ==> 4.6.0
Admob Version ==> Google Mobile Ads Unity Plugin v3.1.3
I am using below code to show interstitial ads.
public const string adsIdAndroid = "ca-app-pub-3940256099942544/1033173712";
public void RequestInterstitial()
{
try
{
if (!AdsFlag)
{
Debug.Log("Requested Interstitial");
// Initialize an InterstitialAd.
interstitial = new InterstitialAd(adsIdAndroid);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
interstitial.LoadAd(request);
}
}
catch (Exception ex) { }
}
public void ShowInterstitial()
{
try
{
//Debug.Log("Try Show InterstitialAd");
if (!AdsFlag)
{
if (interstitial.IsLoaded())
{
Debug.Log("Show InterstitialAd");
interstitial.Show();
AdsFlag = true;
}
else
{
Debug.Log("InterstitialAd Not Loaded");
RequestInterstitial();
}
}
}
catch (Exception ex) { }
}
I am calling above function as below :
void Start()
{
AdsFlag = false;
RequestInterstitial();
}
void Update()
{
ShowInterstitial();
}
Unity Log As Below :
Requested Interstitial
UnityEngine.Debug:Log(Object)
Dummy CreateInterstitialAd
UnityEngine.Debug:Log(Object)
Dummy LoadAd
UnityEngine.Debug:Log(Object)
Dummy IsLoaded
UnityEngine.Debug:Log(Object)
Show InterstitialAd
UnityEngine.Debug:Log(Object)
Dummy ShowInterstitial
UnityEngine.Debug:Log(Object)
But on Real Android Device , ads not showing up..
How to solve this problem ?
Many of us facing similar problem with unity and admob
I just solved this problem by following below steps:
1) I have deleted google-play-services_lib folder at Assets\Plugins\Android
2) Then Select Menu Assets -> Play Service Resolver -> Android Resolver -> Resolve Client Jars.
I just followed this 2 steps and now my google ads working fine.
Maybe this answer help you to figure out problem.

Categories

Resources