Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Interactable Ads button problem.

Discussion in 'Unity Ads & User Acquisition' started by FrASuing, Jan 27, 2019.

Thread Status:
Not open for further replies.
  1. FrASuing

    FrASuing

    Joined:
    Sep 8, 2017
    Posts:
    19
  2. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    No, should work out of the box. If the button isn't enabled, sounds like Ads SDK for some reason isn't ready to show Ads.

    How are you initializing Ads SDK? Also might help to check device logs using command line "adb logcat -v time UnityAds:V *:S" to see Ads related log messages.

    /Rasmus
     
  3. FrASuing

    FrASuing

    Joined:
    Sep 8, 2017
    Posts:
    19
    Thank you for your time,

    So, this is the code attached to the button. In the unity editor, with Play, it works, it appears "This screen would be your Ad unit, everything seems to be working" but when I want to test it on the phone through 'Build and Run' the app runs but the button is enabled.

    Code (CSharp):
    1. [RequireComponent (typeof (Button))]
    2. public class Test_ADS : MonoBehaviour {
    3.  
    4.     public string placementId = "rewardedVideo";
    5.     private Button adButton;
    6.  
    7.     #if UNITY_IOS
    8.     private string gameId = "3020657";
    9.     #elif UNITY_ANDROID
    10.     private string gameId = "3020657";
    11.     #endif
    12.  
    13.     void Start () {
    14.         adButton = GetComponent<Button> ();
    15.         if (adButton) {
    16.             adButton.onClick.AddListener (ShowAd);
    17.         }
    18.  
    19.         if (Monetization.isSupported) {
    20.             Monetization.Initialize (gameId, true);
    21.         }
    22.     }
    23.  
    24.     void Update () {
    25.         if (adButton) {
    26.             adButton.interactable = Monetization.IsReady (placementId);
    27.         }
    28.     }
    29.  
    30.     void ShowAd () {
    31.         ShowAdCallbacks options = new ShowAdCallbacks ();
    32.         options.finishCallback = HandleShowResult;
    33.         ShowAdPlacementContent ad = Monetization.GetPlacementContent (placementId) as ShowAdPlacementContent;
    34.         ad.Show (options);
    35.     }
    36.  
    37.     void HandleShowResult (ShowResult result) {
    38.         if (result == ShowResult.Finished) {
    39. //            GameControl.instance.NewStarWithADS_SURVIVE ();  
    40.         }
    41.     }
    42. }

    I tried with other script, this time, on the test mode on the phone the button is enabled but it does not show any Advertisement


    Code (CSharp):
    1.  
    2. public class ADS_CONTROL : MonoBehaviour {
    3.     string gameId = "3020657";
    4. //    bool testMode = true;
    5.     void Start () {
    6.         Advertisement.Initialize (gameId);//, false);
    7.     }
    8.     void ShowRewardedVideo ()
    9.     {
    10.         ShowOptions options = new ShowOptions();
    11.         options.resultCallback = HandleShowResult;
    12.         Advertisement.Show("rewardedVideo", options);
    13.     }
    14.     void HandleShowResult (ShowResult result)
    15.     {
    16.         if(result == ShowResult.Finished) {
    17.             Debug.Log("Video completed - Offer a reward to the player");
    18. //            SceneManager.LoadScene ("MainGAME_SURV_(2)");
    19.         }else if(result == ShowResult.Skipped) {
    20.             Debug.LogWarning("Video was skipped - Do NOT reward the player");
    21.         }else if(result == ShowResult.Failed) {
    22.             Debug.LogError("Video failed to show");
    23.         }
    24.     }
    25.     public void onCall(){
    26.         if (Advertisement.IsReady ()) {
    27.             Advertisement.Show ("rewardedVideo", new ShowOptions() {
    28.                 resultCallback = HandleShowResult});
    29.         } else
    30.             Debug.Log ("noo");
    31.     }
     
  4. FrASuing

    FrASuing

    Joined:
    Sep 8, 2017
    Posts:
    19
    with the command line:

    adb logcat | findstr -i unity


    I got this result:


    I/Unity (25795): noo
    I/Unity (25795):
    I/Unity (25795): (Filename: ./Runtime/Export/Debug.bindings.h Line: 43)
    I/Unity (25795):


    so it runs the line 30, from the second script

    Debug.Log ("noo");



    ...and with the command line:

    adb logcat -v time UnityAds:V *:S


    I got this result:


    --------- beginning of /dev/log/system
    --------- beginning of /dev/log/main


    that's all
     
  5. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
  6. FrASuing

    FrASuing

    Joined:
    Sep 8, 2017
    Posts:
    19
    It doesn't work, from console I got this error

    [B]E/Unity (23989): AndroidJavaException: java.lang.ClassNotFoundException: com.unity3d.ads.purchasing.IPurchasing
    E/Unity (23989): java.lang.ClassNotFoundException: com.unity3d.ads.purchasing.IPurchasing[/B]
    E/Unity (23989): at java.lang.Class.classForName(Native Method)
    E/Unity (23989): at java.lang.Class.forName(Class.java:251)
    E/Unity (23989): at java.lang.Class.forName(Class.java:216)
    E/Unity (23989): at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    E/Unity (23989): at com.unity3d.player.UnityPlayer.c(Unknown Source)
    E/Unity (23989): at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source)
    E/Unity (23989): at android.os.MessageQueue.next(MessageQueue.java:207)
    E/Unity (23989): at android.os.Looper.loop(Looper.java:123)
    E/Unity (23989): at com.unity3d.player.UnityPlayer$e.run(Unknown Source)
    [B]E/Unity (23989): Caused by: java.lang.NoClassDefFoundError: com/unity3d/ads/purchasing/IPurchasing[/B]
    E/Unity (23989): ... 9 more
    E/Unity (23989): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.unity3d.ads.purchasing.IPurchasing" on path: DexPathList[[zip file "/data/app/com.HorsePower.Test_02-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.HorsePower.Test_02-1, /vendor/lib, /system/lib]]
    E/Unity (23989): at dalvik.system
    E/mono (23989): at UnityEngine.AndroidJavaObject.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
    E/mono (23989): at UnityEngine.AndroidJavaObject.Finalize () [0x00000] in <filename unknown>:0
    E/Unity (23989): java.io.EOFException
    E/Unity (23989):
    E/Unity (23989): (Filename: Line: 432)
    E/Unity (23989):
    I/Unity (23989): error Show


    When I imported Unity Monetization 3.0, Plugins and UnityAds were imported,
    upload_2019-1-29_0-5-10.png

    However, it doesn't allow me to Build the project, I got this error:
    upload_2019-1-29_0-10-58.png
    upload_2019-1-29_0-11-46.png


    I deleted the folder Plugins in order to Build the project, could be this the reason why the ads doesn't work?
     
  7. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    You shouldn't need to delete Plugins folder. What was the reason for deleting that folder?
     
  8. FrASuing

    FrASuing

    Joined:
    Sep 8, 2017
    Posts:
    19
    It doesn't allow me to build the project, I search info about the problem and some users had the same problem, they deleted the folder in order to compile. (They said the folder, or some files are duplicated)

    -Without this Plugins folder I can build the project, that's why I delete the folder. But Unity Ads doesn't work on test mode on the phone.

    -With the Plugins folder I got a message:
    Unable to convert classes into dex format.
     
  9. DenisasK

    DenisasK

    Unity Technologies

    Joined:
    Oct 13, 2016
    Posts:
    89
    It looks like the headers was imported twice. In order to get rid of the error. Please, turn off ads from a service window and remove the ads package from a package manager. It should fix the issue.
     
    Last edited: Jan 30, 2019
  10. FrASuing

    FrASuing

    Joined:
    Sep 8, 2017
    Posts:
    19
    So, following your instructions, now I got this console message:


    I/UnityAds(11045): com.unity3d.services.core.api.Sdk.logInfo() (line:69) :: UnityPurchasing delegate is set
    I/UnityAds(11045): com.unity3d.services.core.api.Sdk.logInfo() (line:69) :: Requesting ad plan from https://auction.unityads.unity3d.com/v4/games/3020657/requests?advertisingTrackingId=9b6bd2e5-dceb-431f-a145-1a6758993f6c&limitAdTracking=false&deviceModel=SM-G318ML&platform=android&sdkVersion=3000&stores=google&deviceMake=samsung&screenSize=98&screenDensity=240&apiLevel=19&screenWidth=800&screenHeight=480&connectionType=wifi&networkType=10
    I/UnityAds(11045): com.unity3d.services.core.api.Sdk.logInfo() (line:69) :: AdPlan received with 1 campaigns and refreshDelay 0
    I/UnityAds(11045): com.unity3d.services.ads.UnityAdsImplementation.show() (line:178) :: Unity Ads opening new ad unit for placement rewardedVideo
    I/UnityAds(11045): com.unity3d.services.ads.UnityAdsImplementation.show() (line:178) :: Unity Ads opening new ad unit for placement rewardedVideo
    W/ActivityManager( 576): Force removing ActivityRecord{429dad18 u0 com.HorsePower.ADs_dos/com.unity3d.player.UnityPlayerActivity t107}: app died, no saved state


    When I push the ads button, it tries to show something, it waits one second the screens turns black and then the app re start again.
     
  11. FrASuing

    FrASuing

    Joined:
    Sep 8, 2017
    Posts:
    19
    So, I create a new project,

    - Switch to android platform
    - Download MOnetizaztion 3.0
    - Disable Ads from windown services
    - delete Ads from package manager
    - attach Example rewarded ads button code to the project
    - request a new game ID from unity DashBoard
    - add my gameID to the script
    - Build and run to test.
    > On the phone, the button is disabled for about 4 seconds, then it's able to push but it only re start the app and no ads are showed

    >> I tried to open this file UnityAdsSetting in ProjectSetting/UnityConnectSettings.asset
    >> I tried to change asset serialization through "Text Only" under Edit -> Project Settings -> Editor and the only option available is -Force Text- but it doesn't work, file.asset
    Manually I rename the file to .txt
    Open the file, and the option m_EnabledPlatforms: 4294967295 and m_AndroidGameId: weren't available.
    I added the missing line and added the android code.
    Manually I rename the file to .asset
    (I don't know if the changes were saved due to I forced the file format)

    From console I got this message

    .core.api.Sdk.logInfo() (line:69) :: Requesting configuration from https://publisher-config.unityads.unity3d.com/games/[B]MyCode[/B]/configuration?bundleId=com.HorsePower.Priest&encrypted=true&rooted=false&platform=android&sdkVersion=3001&osVersion=4.4.4&deviceModel=SM-G318ML&language=en_US&test=false&analyticsUserId=091150f6e2819497494412e9bb3030eb&analyticsSessionId=1326345550071164669&deviceMake=samsung&advertisingTrackingId=9b6bd2e5-dceb-431f-a145-1a6758993f6c&limitAdTracking=false&frameworkName=Unity&frameworkVersion=2018.2.18f1&adapterName=AssetStore&adapterVersion=3.0.1
    I/UnityAds( 6009): com.unity3d.services.core.api.Sdk.logInfo() (line:69) :: Received configuration for token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWMiOjgyLCJjcGkiOjIwNywiaWFwIjoxOTMsImx0diI6NSwicHJvIjoxMDMsInhwciI6OTgsInN1YiI6IldOQzNEdDVGMWpJak53MExVWnFrRVp2Z1k5MVlHZGtTQnIzbEUwVWY2ODdzZENMTVhzS09wK1h2SGNRQ0FiUjk0RUp2T3c9PSIsImlhdCI6MTU0ODg4MjM3MCwiZXhwIjoxNTUwMDkxOTcwLCJpc3MiOiJjb21ldC51bml0eWFkcy51bml0eTNkLmNvbSIsImNyZWF0ZWQiOjE1NDgyMjUzNzYwMDB9.wCZPmhZdTXfONO9t4H4Tf3eByfZGrOCqEmMmhGsnSfU (A/B group 7)
    I/UnityAds( 6009): com.unity3d.services.core.api.Sdk.logInfo() (line:69) :: UnityPurchasing delegate is set
    I/UnityAds( 6009): com.unity3d.services.core.api.Sdk.logInfo() (line:69) :: Requesting ad plan from https://auction.unityads.unity3d.com/v4/games/3026193/requests?advertisingTrackingId=9b6bd2e5-dceb-431f-a145-1a6758993f6c&limitAdTracking=false&deviceModel=SM-G318ML&platform=android&sdkVersion=3001&stores=google&deviceMake=samsung&screenSize=98&screenDensity=240&apiLevel=19&screenWidth=480&screenHeight=800&connectionType=wifi&networkType=10
    I/UnityAds( 6009): com.unity3d.services.core.api.Sdk.logInfo() (line:69) :: AdPlan received with 1 campaigns and refreshDelay 0


    MyCode = unity game ID
    from the message, I look for this line in google
    https://publisher-config.unityads.unity3d.com/games/MyCode/configuration

    >>> I got this message
    {"error":"Game Id MyCode provided is configured for platform android, while ads were requested for platform undefined. Please create own game profiles for each platform release."}

    and from this line
    https://auction.unityads.unity3d.com/v4/games/MyCode/requests

    >>> I got this message
    Method Not Allowed


    What does It mean?
     
    Last edited: Jan 30, 2019
  12. FrASuing

    FrASuing

    Joined:
    Sep 8, 2017
    Posts:
    19
    Is there anybody out there???
     
  13. Rat2ordi

    Rat2ordi

    Joined:
    Oct 2, 2018
    Posts:
    1
    Sorry for the up, but, i have the same problem, and no solution ....
     
  14. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @Rat2ordi

    Since this thread is a bit old, any issues you encounter today are probably not the same issues from this thread. If you are getting ads-related crashes in your game, could you create a new thread and provide more details. Specifically, it would be helpful to know:
    • Are you building your game with Unity, XCode, or Android Studio?
    • If Unity, which version are you using?
    • Which version of the Ads SDK are you using?
    • Can you share the code you are using to integrate Unity Ads?
    • Can you provide a device log from your app when Unity Ads is initialized?
    • Are you using mediation? If so, which version of the mediation SDK and adapter are you using?
    • How pervasive is this problem? Is it reproducible 100% of the time or do you have metrics on how often it happens?
     
Thread Status:
Not open for further replies.