- Home /
Question by
yohanscritch · Feb 13, 2021 at 08:27 PM ·
adscrashing
App crash with Unity Advertisment, here is the log:
Hi there,
When in my game I go from Scene A to B, then back to A, the app crashes in editor and on device (Android). It looks like it happens when trying to initialize Advertisement.
This is the log :
Ad supported
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
AdsController:Initialize() (at Assets/TQGAssets/CS_Assets/CS_Scripts/AdsController.cs:26)
MenuController:Start() (at Assets/TQGAssets/CS_Assets/CS_Scripts/MenuController.cs:54)
(Filename: Assets/TQGAssets/CS_Assets/CS_Scripts/AdsController.cs Line: 26)
/Applications/Unity/Hub/Editor/2020.1.15f1/Unity.app/Contents/Resources/PackageManager/Server/node_modules/winston/lib/winston/logger.js:307
throw ex;
^
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
at doWrite (_stream_writable.js:413:19)
at writeOrBuffer (_stream_writable.js:401:5)
at Socket.Writable.write (_stream_writable.js:301:11)
at Console.log (/Applications/Unity/Hub/Editor/2020.1.15f1/Unity.app/Contents/Resources/PackageManager/Server/node_modules/winston/lib/winston/transports/console.js:79:23)
at Console._write (/Applications/Unity/Hub/Editor/2020.1.15f1/Unity.app/Contents/Resources/PackageManager/Server/node_modules/winston-transport/index.js:82:19)
at doWrite (/Applications/Unity/Hub/Editor/2020.1.15f1/Unity.app/Contents/Resources/PackageManager/Server/node_modules/winston-transport/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/Applications/Unity/Hub/Editor/2020.1.15f1/Unity.app/Contents/Resources/PackageManager/Server/node_modules/winston-transport/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at Console.Writable.write (/Applications/Unity/Hub/Editor/2020.1.15f1/Unity.app/Contents/Resources/PackageManager/Server/node_modules/winston-transport/node_modules/readable-stream/lib/_stream_writable.js:334:11)
at DerivedLogger.ondata (/Applications/Unity/Hub/Editor/2020.1.15f1/Unity.app/Contents/Resources/PackageManager/Server/node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js:681:20)
at DerivedLogger.emit (events.js:201:15)
And this is how my code looks like:
using UnityEngine;
using UnityEngine.Advertisements;
public class AdsController : MonoBehaviour
{
#if UNITY_IOS
public static string gameId = "3977954";
#elif UNITY_ANDROID
public static string gameId = "3977955";
#endif
[SerializeField]
private bool testMode;
// Initialize the ads system
public static void Initialize()
{
if (!Advertisement.isSupported)
Debug.Log("Ad Not supported");
else
Debug.Log("Ad supported");
if (Advertisement.isSupported && !Advertisement.isInitialized)
{
Advertisement.Initialize(gameId, false);
Debug.Log("Initialisation...");
}
}
}
What could be the reason of this?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613025124im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
[ANDROID] signal 11 (SIGSEGV) ON ANDROID 8.0/8.1 WHEN PLAYING GOOGLE INTERSTITIAL/VIDEO AD 2 Answers
Chartboost rewarded ad is crashing Unity Games? 0 Answers
Game crashes after showing intersitial and rewarded ads 0 Answers
How to monetize my facebook canvas game? 2 Answers
How to properly add admob ads to a (unity) android project 0 Answers