I try to show Unity Ads rewarded placement through mediation on Android device, i figured out that its working on android 8 but when i test it on android 9 then UnityAds.isReady() always returns false.
this is the latest mediation gradle configuration.
implementation 'com.google.ads.mediation:unity:3.4.6.0'
this is my configuration code
//UnityAds.initialize(AdTask.this, AdConfig.UNITY_AD_GAME_ID, unityAdsListener,true);//this approach is depecated
UnityAds.initialize(AdTask.this,AdConfig.UNITY_AD_GAME_ID,true);
UnityAds.isInitialized(); // just to making sure that its been initialized
UnityAdsImplementation.addListener(unityAdsListener);
this is how i try to show the ad
if (UnityAds.isReady(AdConfig.UNITY_AD_NEW_TASK_PLACEMENT_ID)) {
UnityAds.show(AdTask.this, AdConfig.UNITY_AD_NEW_TASK_PLACEMENT_ID);
}
and this is my listener class
private class UnityAdsListener implements IUnityAdsListener {
#Override
public void onUnityAdsReady (String placementId) {
// Implement functionality for an ad being ready to show.
}
#Override
public void onUnityAdsStart (String placementId) {
// Implement functionality for a user starting to watch an ad.
}
#Override
public void onUnityAdsFinish (String placementId, UnityAds.FinishState finishState) {
// Implement functionality for a user finishing an ad.
Log.d("unityad","finished");
}
#Override
public void onUnityAdsError (UnityAds.UnityAdsError error, String message) {
// Implement functionality for a Unity Ads service error occurring.
Log.d("ERROR","zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"+message);
}
}
i debugged each steps and found that unity ad gets initialized but ad is not ready to be shown.
log has no clue what is happening therefore i am not sharing the logcat. if any of you have experienced this before then i would love to know how you handled this.
I don't know if it's related, But I'm currently working on my game and ads were working fine, today (like 1 hour ago) i tested my game and the ads were not ready no matter what.. perhaps it's a problem with Google ads?
Related
i have create facebook ad demo app, but can't load any ad(Interstitial ,Native ,Banner) in any version sdk.
if i using sdk version 5.3.0 then facebook ad return error.
Error: New bundles must use latest available Audience Network SDK.
if i using sdk version 5.5.0,5.6.0 then facebook ad return error.
Error: No fill
i also tried live ad id(264476213973610_264482430639655) and testing ad id (YOUR_PLACEMENT_ID) but doesn't work
AudienceNetworkAds.initialize(this);
final InterstitialAd interstitialAd = new InterstitialAd(MainActivity.this, "YOUR_PLACEMENT_ID");
AdSettings.addTestDevice("6f2e675e-05b0-46d8-b3d6-032ef6a25fdb");
interstitialAd.destroy();
interstitialAd.setAdListener(new InterstitialAdListener() {
#Override
public void onInterstitialDisplayed(Ad ad) {
Log.e(TAG, "Interstitial ad displayed.");
}
#Override
public void onInterstitialDismissed(Ad ad) {
Log.e(TAG, "Interstitial ad dismissed.");
}
#Override
public void onError(Ad ad, AdError adError) {
Toast.makeText(MainActivity.this, "Error: " + adError.getErrorMessage(), Toast.LENGTH_LONG).show();
}
#Override
public void onAdLoaded(Ad ad) {
Toast.makeText(MainActivity.this, "Loaded: " + ad.getPlacementId(), Toast.LENGTH_LONG).show();
interstitialAd.show();
}
#Override
public void onAdClicked(Ad ad) {
Log.d(TAG, "Interstitial ad clicked!");
}
#Override
public void onLoggingImpression(Ad ad) {
Log.d(TAG, "Interstitial ad impression logged!");
}
});
interstitialAd.loadAd();
I had faced a similar issue. So I'll explain how I solved it.
To test properly on your device, you need to follow some other steps too other than you mentioned in the question.
STEPS:
Properly follow the interstitial, banner, etc. documentation to integrate ads
Download the official Facebook app (which is required to get test ads) and log in using either tester's account or Admin's account of the Audience Network. FB doesn't return ads if it doesn't find its official app on the device because it crawls the data of the account to provide the relevant ads to the user
Add test device to get test ads (or live ads for testing which doesn't give you revenue). To add a device:
i) Login to your Audience Network account
ii) Go to Monetization Manager > Integration > Testing
iii) Add test device using Android's AAID or iOS's IDFA. You can check other SO's threads to find AAID or IDFA of the device, in case you don't know.
iv) You can test it in the device now and you must be getting ads. If still there are no ads, select Use real advertiser content option there itself. Now to test different type of ads like HD Video, Simple Image or such; Click Select Ad Type on the same screen
NOTE: Remember to check the article on FAN's ad Caching in Android 9+ because HD Video or any type of video ads won't show on Android 9+ and you might get a blank screen blocking all the functionalities of your app.
use sdk version com.facebook.android:audience-network-sdk:5.11.0
I use google-play-services 8.1.0 (but it was tested on 7.8.0 as well). I create AdMob interstitial with this code:
_interstitialAd = new InterstitialAd(this);
_interstitialAd.setAdUnitId(getString(R.string.interstitial_admob));
_interstitialAd.setAdListener(new AdListener() {
#Override
public void onAdClosed() {
Logger.log("onAdClosed");
requestNewInterstitial();
}
public void onAdFailedToLoad(int errorCode) {
Logger.log("onAdFailedToLoad");
}
public void onAdLeftApplication() {
Logger.log("onAdLeftApplication");
}
public void onAdOpened() {
Logger.log("onAdOpened");
}
public void onAdLoaded() {
Logger.log("onAdLoaded");
}
});
requestNewInterstitial();
After some user actions I call
if (_interstitialAd.isLoaded()) {
_interstitialAd.show();
return;
}
But it takes some time before ad is shown. I've added some log messages and they show that ad is loaded onAdLoaded is called.
I measured delay before ad display and each time it's different. On Nexus 5 (marshmallow) it's from 100ms, which is good to 1500ms which is not good, but comfortable. But on other devices such Nexus 7 (2012) and Nexus 10 it's varies from 4s, to even 6s which is awful.
Also I got issue which messed up my fragments lifecycle. And I had to change fragments pop from backstack and this helps (I don't remove fragments before ads show but do this after onAdClosed), but this steps doesn't remove delay before ad display.
All this steps were done on 8.3.0 as well
Can anybody helps me to remove this delay?
I noticed this with some ads this week. It seems they are serving a new type of interstitial that is causing this delay, because it never happened before. I temporarily disabled text and image ads (because video ads seem to work well) until it's fixed.
You don't quantify what delay you are experiencing. So it is very hard to answer this question. But if the ad has already been downloaded before you call show() then the only delay will be rendering, which is impacted by the hardware you run on and the other processing that you are doing at the time.
need a little help. Im making an android app and integrated Soomla for a simple "No ads" purchase inside my app. Ive a purchase button which should do the actual purchase via google.
What occurs is a popup from google : "Error
authentication needed, You have to login in your google account" .
I think its a small problem, but i dont get what. I am logged in in my google account. Store in Soomla is running ( at least it says so). ive enable test purchase.Im using my phone for the purchase ofc. What i am missing?
public class NoADsButton : MonoBehaviour {
private static bool storeInitialized = false; // prevent store to be initialized twice
void Start () {
if(storeInitialized) return;
SoomlaHighway.Initialize();
StoreEvents.OnSoomlaStoreInitialized += onSoomlaStoreInitialized;
SoomlaStore.Initialize(new SoomlaAssets());
}
public void onSoomlaStoreInitialized() {
storeInitialized = true;
}
public void OnMouseDown(){
StoreInventory.BuyItem("no_ads");
}
And the item ive done as its shown in the soomla example:
public const string NO_ADDS_PRODUCT_ID = "no_ads";
public static VirtualGood NO_ADS_LTVG = new LifetimeVG(
"No Ads", // name
"No More Ads!", // description
"no_ads", // item id
new PurchaseWithMarket(NO_ADDS_PRODUCT_ID, 0.99)); // the way this virtual good is purchased
}
This usually happens when the process of publishing the app for testing wasn't done properly. Try going carefully over Google's instructions, make sure you didn't miss anything. http://developer.android.com/google/play/billing/billing_testing.html#billing-testing-test
Lately, I have been trying to add static interstitial ads into my Unity game. For some reason, I could not get the system to show anything, or even react to me. After trying to work with the base Chartboost plugin, I tried to match a tutorial that I was following and purchased Prime31's Chartboost plugin and have been using that. However, neither the base plugin, nor Prime31's plugin, seem to be allowing me to show any ads. The code is pretty much done inside a single object, and it seems simple enough.
public class Advertisement : MonoBehaviour {
public string chartboostAppID = "5461129ec909a61e38b1505b";
public string chartboostAppSignature = "672b3b34e3e358e7a003789ddc36bd2bc49ea3b5";
// Use this for initialization
void Start () {
DontDestroyOnLoad(this.gameObject);
ChartboostAndroid.init (chartboostAppID, chartboostAppSignature, true);
ChartboostAndroid.cacheInterstitial(null);
}
void OnLevelWasLoaded(int level) {
ChartboostAndroid.cacheInterstitial(null);
if(Application.loadedLevelName == "Network Lobby") {
showAds();
}
}
public static void showAds() {
Debug.Log("Showing ad");
ChartboostAndroid.showInterstitial(null);
}
}
As you can see, it's pretty straightforward. This object is created at the game's splash screen, which appears only once, and it's never destroyed until the program ends. The goal is, whenever I enter the lobby scene, I want to see an ad before going to the lobby's menus. As it is, I do see the log printing "Showing ad", so I know the function is being called. However, nothing appears. Do I need to disable the GUI system first? Is there a step I'm missing?
I have already performed the following steps:
I have created and registered the app with chartboost, as well as double and triple checked the AppID and App Signature.
I have created a publishing campaign and registered it to the app.
I double-checked the orientation and confirmed that it's correct.
I registered this specific device as a test device.
The tutorial showed a call to ChartBoostAndroid.OnStart(), but there was no function like that for me to call. Perhaps that is from an older version?
I emailed Chartboost support and have not heard from them yet. I do not have that much time on this project, so if anyone can offer help, I'd appreciate it.
I'm writing a game in android using Google Play Games Services. I want to get other players using GamesClient.loadPlayerCenteredScores. The problem has to do with getting the profile image. I use getScoreHolderIconImageUri() and fetch the URI with ImageManager.loadImage. My image loaded listener never gets called and games services stops working like a second after the call, the game continues normally (As if games services was disconnected) and I don't get any error in the log whatsoever except for a warning.
Here is the code:
public void PlayersLoader(){
getMainActivity().getGamesClient().loadPlayerCenteredScores(
new OnLeaderboardScoresLoadedListener(){
#Override
public void onLeaderboardScoresLoaded(int statusCode, LeaderboardBuffer leaderboard, LeaderboardScoreBuffer scores){
if(statusCode==0){
LeaderboardScore score;
String playerId=getMainActivity().getGamesClient().getCurrentPlayer().getPlayerId();
ImageManager imMan=ImageManager.create(getContext());
for(int i=0;i<scores.getCount();i++){
score=scores.get(i);
String name;
if(score.getScoreHolder().getPlayerId().equals(playerId)){
name=getResources().getString(R.string.your_best);
}
else{
name=score.getScoreHolderDisplayName();
}
Uri imuri=score.getScoreHolderIconImageUri();
if(imuri!=null){
imMan.loadImage(new ImageLoaded(name),imuri);
}
}
System.out.println("Finish");
scores.close();
leaderboard.close();
}
}
},getResources().getString(R.string.HighScores),LeaderboardVariant.TIME_SPAN_ALL_TIME,
LeaderboardVariant.COLLECTION_SOCIAL,10);
}
}
class ImageLoaded implements OnImageLoadedListener{
String mName;
public ImageLoaded(String name){
mName=new String(name);
System.out.println(mName);
//This does get printed out (the names of the players)
}
#Override
public void onImageLoaded(Uri uri, Drawable drawable){
System.out.println("imageLoaded"); //This never gets printed out
}
}
This is what I get in the log:
//Your Best
//Player 1 Name
//Player 2 Name
//Finished
//Games Services has stopped working dialog in phone, when I click OK, this warning shows:
//*** Unexpectedly disconnected. Severing remaining connections.
If I remove the ImageManager call and print out the names only, they get printed out correctly and nothing stops working.
I don't know what's happening, I'm desperate.
EDIT
Even if I comment this line:
imMan.loadImage(new ImageLoaded(name),imuri);
the error happens.
It is only when I remove this that it stops happening:
Uri imuri=score.getScoreHolderIconImageUri();
It's so strange! Even if I do not do anything with imuri.
EDIT I posted the issue here. It seems it was a bug of Google Play Services. Sure they will fix it soon!
Sounds like maybe you're running into the same problem described in the public bug tracker. If so, a fix is inbound and things should be working again Real Soon Now[tm].