Flutter, admob dispose not working sometimes - flutter

I`m using "firebase_admob" package https://pub.dev/packages/firebase_admob
and my code is below
static void hideBannerAd() {
if (_bannerAd != null) {
_bannerAd.dispose();
_bannerAd = null;
}
}
All of my ads functions are defined as static and this works perfectly.
Currently I am turning off ads on my app's specific page.
However, since releasing my app, certain customers have found that hideBannerAd is not working properly.
On a particular page, they say that there are times when the ad is turned off well and sometimes it is not, once it is not turned off, it will never turn off(Even if they go in and out of that particular app's screen page) .
On my device this works perfectly without any of error.
If you turn off and turn on the AdMob banner frequently, is there a case where the network is tangled and it does not work properly?
Any advices would be appreciate

I had this problem on a project a while ago, this is a package bug. Here are a few similar unresolved GitHub issues : #96, #669, #3056, #3900. The package have been poorly maintained, but this might change due to the recent FluterFire reorganization.

Related

Google play list this error Broadcast of Intent { act=android.accounts.LOGIN_ACCOUNTS_CHANGED

I got following error on google play store but I have no idea why this error occured. They said that it is happing on (Sharp AQUOS sense2 SH-01L Android 9 (SDK 28) ).
I have logcat but I can't find anything in logcat too. I already released to production. This one is my bugs fixed for new release.
ANR in com.google.android.apps.tachyon;PID: 18069;Broadcast of Intent {
act=android.accounts.LOGIN_ACCOUNTS_CHANGED flg=0x5000010 cmp=com.google.android.apps.tachyon/com.google.apps.tiktok.account.data.device.DeviceAccountsChangedReceiver_Receiver };
A similar Error occurred for me as well.
"ANR in com.google.android.apps.tachyon" at same device "Sharp AQUOS sense2 SH-01L"
E/ActivityManager(1566): ANR in com.google.android.apps.tachyon
E/ActivityManager(1566): PID: 18457
E/ActivityManager(1566): Reason: Broadcast of Intent { act=android.intent.action.LOCALE_CHANGED flg=0x11200010 cmp=com.google.android.apps.tachyon/.common.applifecycle.LocaleChangeReceiver }
I believe this device has com.google.android.apps.tachyon app is installed by default and an automatic update for this app could be running in the background (just a guess) which crashes anytime.
The crash is just a coincidence.
It will not happen every time with the same app and with the same use case. It will also not happen with any other device. just update the versionCode and publish the App again.
One other option is to go to the device catalog and mark this device as not supported.
After a lot of research, I think I have finally solved this for my app.
In my case, other than my main activity, the other Activies were only called by my app. In my activities in my AndroidManifest.xml, I had
android:exported="true"
Of course, this allows these activities to be invoked by other external activities/etc
By changing this to:
android:exported="false"
...it prevents the activity from being called.
In my case and going through the logs, I didn't see anything that jumped out and bit me but my research led me to believe that com.google.apps.tiktok.* was some sort of old transactional piece of Android. Also, I noticed my Tutorial activity was logging well after it should have been.
My suspicion is the test may actually be real and intended to check for either Activities handling external launches or checking for a security injection of some kind.
I think the use case is likely that an Android user is changed on the phone (usually at end of these robo tests), ticktok handles that and sends this intent/message to all externally known Activities. If so, that would mean either the Activities have to not be exported or handle the intent appropriately.
Anyhow, this change helped me tremendously and I haven't hit this with this app since after about 100 robo tests. Hope it helps someone else.
I think this is a problem with Google Play Store testing devices. Problems went away without me making any changes on a new release.

Adgamer interstitial ad doesn't show

I'm trying to implement AdGamer SDK in my Unity game. I'm calling AdGamer.InterstitialAds.Show() but it doesn't show anything. Please help
It could be for several reasons:
The interstitial hasn't yet been loaded. So, check AdGamer.InterstitialAd.IsReady() before trying to show an interstitial ad
The SDK hasn't yet been initialized. Make sure to call AdGamer.InitWithGameToken(YOUR_GAME_TOKEN); before calling anything else in the AdGamer SDK. For example, you can do that in Awake() method in a script which you put on some GameObject in the first scene your game loads. Or you could create a static method with the attribute [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
to make it run at game launch before anything else. It can be in any script and there you'd initialize the SDK. The game token you get when you register your game in the AdGamer publisher console.
The initialization of the SDK may take several seconds (e.g. it may need to auto-update), so if you're trying to show an interstitial very early (right at game launch, before the starting screen) the call will likely fail. For such cases you may want to check AdGamer.IsInitialized before doing anything else.
// in any script
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
public static void InitializeAdGamerBeforeEverything()
{
AdGamer.InitWithGameToken(YOUR_GAME_TOKEN);
}
// elsewhere in code
if (AdGamer.IsInitialized && AdGamer.InterstitialAd.IsReady())
{
AdGamer.InterstitialAds.Show();
}
There is no internet connection or some firewall or other settings on your machine prevent the game from connecting with AdGamer servers
Note that the "no_fill" case doesn't exist in AdGamer: it should return at least a cross-promo ad even if no commercial ad is available in your country at the moment.
Also, please be sure to check the SDK documentation (it also comes as a PDF file inside the unitypackage)

Flutter : Attempt to remove non-JNI local reference, dumping thread

I am relative new to Flutter.After playing around with adding ads to my app (emulator implementation so far - using firebase admod plugin - latest version), the console keeps spawning the following message
Attempt to remove non-JNI local reference, dumping thread
Firstly, I considered as a warning of something. However, the app's performance keeps decreasing and sometimes causing some services to fail.I made an apk build in order to test the behavior at a mobile, but still I haven't seen any ads in order to see any performance hiccups (newly subscribed to admob so it take some time to serve ads). When I remove completely all the code for the ads the performance comes back to its standards.
Another strange thing is that when I use the
adUnitId: BannerAd.testAdUnitId,
it gives me the same message 4-5 times and then stops. However, with real adUnitId keeps logging the same message over and over again.
I saw related subjects, but none of them referring to Flutter.
I would appreciate any advice. Probably, I do something wrong.
Thanks in advance.
A first-party plugin google_mobile_ads has been recently launched and the Flutter team recommends using this plugin going forward.

How to check if Chartboost interstitial is loaded?

For somehow I don't get Chartboost interstitial loaded every time, asked them and as most answers:"no more of the interstitials available at the time you're testing in the network satisfy the conditions......". So now I use revmob also. The question I have: how to check if Chartboost is preloaded? my code so far:
if(Chartboost.hasInterstitial(CBLocation.Default))
{
Chartboost.showInterstitial(CBLocation.Default);
}else {
revmob.ShowFullscreen();
}
I only receive revmob interstitials. Is my checking condition ok? Saw something about delegates but I am not sure how to use them.
Yes you checking condition is OK.
For using delegates read this Chartboost Documentation on delegates in Unity3D. I think it has a pretty good explanation on how to implement delegate methods. Also I will HIGHLY recommend that you do implement these delegate methods as they will help you not only with displaying ad status logs but also identifying problems regarding Ad display.
EDIT for future reference:
For example:
Implementing Chartboost.didCacheInterstitial and Chartboost.didFailToLoadInterstitial delegates will tell you if and when an interstitial ad was loaded or failed. The fail delegate(s) also sends an error as parameter so you would know why the cache was failed.
If the delegates are not being called then there is an issue with your chartboost SDK integration in your project inside unity. In that case try re-importing the chartboost sdk and check you chartboost dashboard for issues. One of the most common issues >> make sure that there is an active ad campaign linked to your in chartboost dashboard. To setup an ad campaign follow: Start a Publishing Campaign

iOS 6 breaks GeoLocation in webapps (apple-mobile-web-app-capable)

I have an app that does a simple textbook navigator.geoLocation.watchPosition(...) that works great in iOS 5.x both in Safari and as a web app (using apple-mobile-web-app-capable meta tag).
However, in iOS6, GeoLocation does not work in the webapp. It still works in safari as expected, but when I run the webapp, it prompts me for location permission, then silently fails. I see the location icon, but no events are thrown from watchLocation. I get no error events or any location events.
Has anyone run into this? Any workarounds? It's definitely iOS6 specific and also specific to the apple-mobile-web-app-capable/webapp.
This is definitely a bug but I found a work around. You aren't going to like this but at least it will get your web app working again. You need to examine the User Agent header and if it contains "iPhone OS 6" then do not use:
<meta content="yes" name="apple-mobile-web-app-capable" />
Yes, this means that it won't be a true web app and you will get the Safari header and footer bars. But at least it will make your app work again from the home screen. You can see how this works by going to my site www.nextbus.com.
Note that it appears that Google ran into this problem. Try going to maps.google.com and then adding the web app to your homescreen. The geolocation will work for it but you will indeed see the ugly Safari header and footer bars.
Please complain loudly to Apple!
The good news is: I've done it... I've figured it out. The bad news is: somebody smarter than me is going to have to tell you why this works, whereas any other variation of this solution or any of the other solutions offered don't work. This was a hard-fought victory but I'm too embarrassed to say how many hours (days) it took me to figure this out. Without further ado:
if (window.navigator.geolocation) {
var accuracyThreshold = 100,
timeout = 10 * 1000,
watchID = navigator.geolocation.watchPosition(function(position) {
$('#latitude').val(position.coords.latitude); // set your latitude value here
$('#longitude').val(position.coords.longitude); // set your longitude value here
// if the returned distance accuracy is less than your pre-defined accuracy threshold,
// then clear the timeout below and also clear the watchPosition to prevent it from running continuously
position.coords.accuracy < accuracyThreshold && (clearTimeout(delayClear), navigator.geolocation.clearWatch(watchID))
}, function(error) {
// if it fails to get the return object (position), clear the timeout
// and cancel the watchPosition() to prevent it from running continuously
clearTimeout(delayClear);
navigator.geolocation.clearWatch(watchID);
// make the error message more human-readable friendly
var errMsg;
switch (error.code) {
case '0':
errMsg = 'Unknown Error';
break;
case '1':
errMsg = 'Location permission denied by user.';
break;
case '2':
errMsg = 'Position is not available';
break;
case '3':
errMsg = 'Request timeout';
break;
}
}, {
enableHighAccuracy: true,
timeout: timeout,
maximumAge: 0
}),
delayClear = setTimeout(function() {
navigator.geolocation.clearWatch(watchID);
}, timeout + 1E3); // make this setTimeout delay one second longer than your watchPosition() timeout
}
else {
throw new Error("Geolocation is not supported.");
}
Note: for some reason, this doesn't seem to work as consistently if the execution of this code it delayed at some point after initially launching the app. So, this is the FIRST thing I execute in my initialization method.
Note: The only other thing I've added to my app is, when I need to use the geolocation data (which, for me, takes place after the initialization of several other Classes/Object Literals), is to check for the latitude/longitude values. If they exist, continue; If not, run the above geolocation method again, then continue.
Note: One of the things that threw me for a long time was that I only needed to get the current position of the user. I didn't need to track the users' movements. I kept trying different iterations of this with the getCurrentPosition() method. For whatever reason, it doesn't work. So, this is the solution I came up with. Run it like you're going to track the users location (to get their location in the first place), then once you've gotten their location, clear the watchPosition ID to prevent it from tracking them. If you need to track their location as it changes over time, you can of course... not clear the watchPosition ID.
HTH. From everything I've been reading, there are a lot of developers who need this functionality to work for their mission-critical apps. If this solution doesn't work for you, I'm not sure what other direction I can give. Having said that, I've tested this several hundred times and this successfully retrieves the users' location in a WebApp (navigator.standalone) on iOS 6.
here is a video of me replicating the bug and demonstrating a work around. This bug appears to exist weather you use the web app meta tag or not.
http://youtu.be/ygprgHh6LxA
Update: 121212 - IOS 6.1 Beta 3 testing shows the bug is still not resolved...
Update: 122012 - IOS 6.1 Beta 4 testing shows the bug is still not resolved...
Update: 031113 - Replication Example
Okay, it is a simple issue to replicate in just a few seconds. I feel it is not a safari, but an IOS issue. It’s almost as if Google wrote the bios for the IOS to meet the WC3 html geo location spec and took it with them when IOS6 kicked them off the bus.
Using an IOS device go here:
http://uc.myaesc.com/geoloctestorig.htm
Click start, watch should return result almost every second.
Then click the Google link to leave this page.
Then user browser back button to return
Click start.
Watch will return 1 to 3 records and hang.
Minimize safari (home button) and then restore (safari icon); stops hanging
That's it. until it does not hang, the issue remains.
Mark
UPDATE:
IOS 7.1 fixed the issue...
It appears it only works once, then any secondary calls fail. One alternative is to cache the result and use the cached result if you have one, though this means you can't have an app that follows someone's position.
This is not exactly an answer as it seems like Home Screen apps in ios6 has some bug related to GeoLocation, but I found the following link very helpful. It explains that as Home Screen apps are now stored like native apps, they have their own storage/caching.
Geolocation works on the first iteration but fails to update from then on. the work around is to remove the following meta tag so that Home Screens app run in Browser mode (I am not sure if it is exactly call a Browser mode). The app will unfortunately render with the browser headers and footers, but GeoLocationwill be working again.
<meta content="yes" name="apple-mobile-web-app-capable" />
iOS 6 Geolocation and Local Data Storage
"Data in Home Screen apps are now stored like native apps. Native apps each have their own sandbox where their data is stored, backed up and restored to. Prior to iOS 6, Home Screen apps shared data with the same app running in the browser. If the user cleared the cache in the browser, the Home Screen version of the app would lose its data too.With iOS 6, Home Screen apps’ data gets saved to a sandbox just like native apps. Backups and restores handle the data properly, and clear cache in the browser will not affect them."
I'm having the same problem. Looks like watchPosition is simply failing out after the first position is received. I haven't found a work around yet, but I wanted to confirm that I was experiencing issues.
Using these samples:
http://www.w3schools.com/html/html5_geolocation.asp
I get expected results on ios5 but ios6 drops the ball with watchPosition.
I can confirm I get the same problem when running my web app in fullscreen.
Interestingly, when Safari in Fullscreen asked permission to use my location, the website title was 'web' rather than the title of the website, as in previous versions of iOS.
Removing the "apple-mobile-web-app-capable" meta tag is fine, and it works, but only if you "Add to Homescreen" again. We have ~7000 daily users who have already added our icon to their homescreen. Getting them to do so again, then potentially again when a fix is implimented isn't great.
This appears to be fixed under iOS 6.1! It wasn't in the recent betas, but today's final 6.1 release seems to be good with my testing.
seems to be fixed in iOS 6.1, finally! See my site www.slople.com where it works again under 6.1
This is FINALLY fixed in iOS7 beta (beta 2 is all I've tested)!
You must take care of non secure content loaded. For me loading all javascript, images and css from secure context solved the problem with safari.