Hello, i had a game, and i have connecting monetization with Unity Ads. I have write a Script to play a Ad on a start from a Scene:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
public class FinishAD : MonoBehaviour
{
public string myGameIdAndroid = "MY CODE";
public string myGameIdIOS = "MY CODE";
public string adUnitIdAndroid = "Interstitial_Android";
public string adUnitIdIOS = "Interstitial_iOS";
public string myAdUnitId;
public bool adStarted;
private bool testMode = true;
// Start is called before the first frame update
void Start()
{
#if UNITY_IOS
Advertisement.Initialize(myGameIdIOS, testMode);
myAdUnitId = adUnitIdIOS;
#else
Advertisement.Initialize(myGameIdAndroid, testMode);
myAdUnitId = adUnitIdAndroid;
#endif
}
// Update is called once per frame
void Update()
{
if (Advertisement.isInitialized && !adStarted)
{
Advertisement.Load(myAdUnitId);
Advertisement.Show(myAdUnitId);
adStarted = true;
}
}
}
I created a AdDisplayObject (A empty Object in the Scene) and put my Script in. I have test it out and all seems to work. But then when i tried to build (in a ".apk" ) then this Screen shows:![alt text][1]
I clicked "Ignore" and in a few seconds this Screen shows: ![alt text][2]
with this errors:
workingdir, System.String task, System.Action`1[T] progress) (at :0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at :0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at :0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at :0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <7ac35247888b44f4a7e290f1f6bb33f3>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
i have absolutely no idea how to fix it. Can anyone Help? (sorry for my bad english)
[1]: /storage/temp/204404-screenshot-2023-02-02-165422.png
[2]: /storage/temp/204405-screenshot-2023-02-02-165522.png
↧