Android crashes on Initialization.

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.

Thanks,
Dan

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?

1 Like

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.

2 Likes

I will do all of the above when I get home and report back. Thanks for the quick response, I appreciate it.

1 Like

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.

1 Like

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.

Thanks,
Dan

1 Like

This seems to be related to adblocking on some Android 5 devices. We’ve gotten one other report about crashing with android 5 & adblock.

This does not happen on all android 5 devices, we’ve so far been able to re-produce this with jailbroken android 5 with adblock.

Android 5 does not yet today have significant share on the marketplace (Distribution dashboard  |  Platform  |  Android Developers) , but we will look into this as soon as possible.

Cheers,
Heikki

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.

Thanks for looking into it.

What ROM were you using?

H

It was not this version, but an older version of this ROM for the Nexus 5.
http://forum.xda-developers.com/google-nexus-5/development/rom-xtraslim-1-0-stock-odex-optimized-t2924150

And you can see in the features, it blocks ads using the hosts file.

- No ADS (blocked from host file) no more ads on app and browser;
1 Like

Thanks! Disabling Stripping for Android solved this in Unity 5.3.1f1 for me.

Is there a way to bypass this in the latest version without disabling stripping for Android?

The bug has been reported here: Unity Issue Tracker - Using Unity Ads and Stripping crashes project on Android and the Android team is looking into fixing it. Will follow up here when we have more information

1 Like

The bug has been fixed internally now, and will let you know here as soon as we have verified and released it

1 Like

Any update on it? I am experiencing the same problem right now. UnityAds + Android = crash.

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.

-Rasmus

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?

Which version of Unity/Ads are you using?

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?

Btw, what is the reason you are exporting to Android Studio project?