I am trying to implement UnityAds into an android game. It works fine showing the sample ads in the editor, but as soon as I attempt to build and run it on device, it closes as soon as I try and Initialize.
Right before I see the WIN DEATH log in the Logcat it logs this error:
UnityAds: com.unity3d.ads.android.webapp.f.b() (line:755) :: Problems opening stream: failed to connect to impact.applifier.com/127.0.0.1 (port 443) after 20000ms: isConnected failed: ECONNREFUSED (Connection refused)
I googled some and only came across one other instance of this being report and I could get no help out of reading the thread.
This is using the latest build from the Asset Store, starting with a blank Unity Project and creating a Non-Released game on the UnityAd’s site.
The only thing in the project is the script from the integration guide attached to the camera. I did this to remove any other issues that could have been happening with my main game.
Has anyone else encountered this? Or can see a missed step that I missed in integrating Ads into android.
Could this be a case of not being able to test Ads in a game that is still only in development? Can you only hit the UnityAds server for games that are currently live?
@unity-nikkolai , I see that you are on these boards answering questions fairly frequently, any chance you have any ideas as to why I could be having issues?
Your game doesn’t need to be live to see ads. You can run in Development Mode and it’s recommend to initialize Unity Ads in your game with test mode enabled while testing.
Did you move any of the Unity Ads assets around in your project after importing? Might be worth removing the existing version of Unity Ads from your project, just by deleting the files. Then download and import it again.
If you have the Stripping Level set to anything other than Disabled in Player Settings, you’ll need the file named “link” in the Assets directory of your project. This ensures you keep libraries for www classes.
Could you copy the logcat output from startup to crash to a gist and share that with me? Also, if you wouldn’t mind, try building one of the example scenes in this project to see if you get the same results.
I built the Unity Ads demo and pushed to my Nexus 5 and it crashed at Initialization. I have copied over the Logcat, the initialization starts at line 295.
I am going to try and find another device to test on, as if your project normally works it must be my device.
Ok, I tested on another phone and your project works fine. My guess is that the rom that is on my other device must have some sort of ad blocking built in, which for some reason causes the UnityAd code to completely bomb and close the app.
I was going to request to close the thread, but I will leave open as maybe you or someone else on the UnityAds team could code around this scenario and prevent the application from crashing when this occurs during initialization.
Awesome, Glad you are able to reproduce the issue. That is the same scenario I was in when noticing it, but I think the adblock was baked into the rom. Once I switched roms on the phone it worked as expected.
It’s set to be released with Unity 5.3.3, and I’ll let you know here as soon as it’s released in a patch build (most likely during February). Another workaround is to select IL2CPP in player build settings.
My android game still crashes with Unity ads installed. I can’t seem to find anything other than this page on it. Can anyone suggest links to trouble shooting this?
I’m using the latest version of unity and I turned ads on via services tab. I’m using the sample code for interstitial ads. It works in the editor and as a test apk that I’ve loaded on my android. It does not work when I export it as a Google Android Project.
I’ve created a play again UI game button. Attached the script to the canvas. Added the onclick function to the button.
using UnityEngine;
using UnityEngine.Advertisements;
public class unity_ad : MonoBehaviour
{
public void ShowAd()
{
if (Advertisement.IsReady())
{
Advertisement.Show();
Application.LoadLevel ("scene2");
}
}
}
Thanks for info about building from Android Studio. Can you please check your adb log from device, if it contains information about the crash? E.g. have you added/changed ProGuard settings in your project?