Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Bug Unity Ads 3.7.5 missing permission and ads not shown in build?

Discussion in 'Unity Ads & User Acquisition' started by Ohyouknow, Oct 22, 2022.

  1. Ohyouknow

    Ohyouknow

    Joined:
    Oct 23, 2013
    Posts:
    135
    Hi all and @LIU_Hanyang96 - @kyle-unity - @ads-adam-unity - @JeffDUnity3D

    I'm running into a weird issue with ads. My game has been in Google Play since 2016, and ads still function fine. I was updating things for a new release and although everything is the same, when trying ads on an Android device with my latest build, it doesn't show the ad. Everything works fine in the editor though.

    I'm on 2020.3.38f1 with Unity Ads 3.7.5 (I have to stick with that for now because it'll break other scripts). I've tried different ad SDK's but getting the same result. I've required internet access in player settings, and manually added network access state and internet to the manifest. Product ID's and dashboard setup is accurate. Not in test mode.

    I'd love any help with figuring this out. Thank you!

    Manifest:
    Code (CSharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.unity3d.player" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
    3.   <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
    4.   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    5.   <uses-permission android:name="android.permission.INTERNET" />
    6.   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    7.   <application android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
    8.     <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name">
    9.       <intent-filter>
    10.         <action android:name="android.intent.action.MAIN" />
    11.         <category android:name="android.intent.category.LAUNCHER" />
    12.       </intent-filter>
    13.       <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    14.     </activity>
    Current Ad's code I'm running in my first scene to initialize ads:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Advertisements;
    3.  
    4. public class NewUnityAds : MonoBehaviour
    5. {
    6.     [SerializeField]
    7.     private string
    8.     androidGameId = "idgoeshere",
    9.     iosGameId = "idgoeshere";
    10.  
    11.     [SerializeField]
    12.     private bool testMode;
    13.  
    14.     void Start ()
    15.     {
    16.         string gameId = null;
    17.  
    18.         #if UNITY_ANDROID
    19.         gameId = androidGameId;
    20.         #elif UNITY_IOS
    21.         gameId = iosGameId;
    22.         #endif
    23.  
    24.         if (Advertisement.isSupported && !Advertisement.isInitialized) {
    25.             Advertisement.Initialize(gameId, testMode);
    26.         }
    27.     }
    28. }
    The log cat is saying:
    2022/10/22 12:28:14.212 20386 20420 Debug UnityAds com.unity3d.services.core.misc.Utilities.writeFile() (line:127) :: Wrote file: /data/user/0/com.companyname.appname/files/UnityAdsStorage-public-data.json

    2022/10/22 12:28:14.217 20386 20420 Debug UnityAds com.unity3d.ads.UnityAds.initialize() (line:636) :: ENTERED METHOD

    2022/10/22 12:28:14.217 20386 20420 Debug UnityAds com.unity3d.services.ads.UnityAdsImplementation.initialize() (line:72) :: ENTERED METHOD

    2022/10/22 12:28:14.254 20386 20483 Info UnityAds com.unity3d.services.core.configuration.InitializeThread$InitializeStateConfig.execute() (line:289) :: Unity Ads init: load configuration from config.unityads.unity3d.com/webview/3.7.5/release/config.json

    2022/10/22 12:28:15.315 20386 20577 Info UnityAds com.unity3d.services.core.api.Sdk.logInfo() (line:84) :: Requesting configuration from publisher-config.unityads.unity3d.com/games/

    2022/10/22 12:28:15.442 20386 20386 Info chromium [INFO:CONSOLE(0)] "Uncaught (in promise) [object Array]", source: file:///storage/emulated/0/Android/data/com.companyname.appname/cache/UnityAdsCache/UnityAdsWebApp.html?platform=android&origin=https%3A%2F%2Fconfig.unityads.unity3d.com%2Fwebview%2F3.7.4%2F31a458ff4707db1093f4d425a392de90933316c4%2Frelease%2Findex.html&version=31a458ff4707db1093f4d425a392de90933316c4 (0)

    2022/10/22 12:28:15.482 20386 20577 Info UnityAds com.unity3d.services.core.api.Sdk.logInfo() (line:84) :: Requesting ad plan from auction.unityads.unity3d.com/v6/games/

    2022/10/22 12:28:14.254 20386 20483 Info UnityAds com.unity3d.services.core.configuration.InitializeThread$InitializeStateConfig.execute() (line:289) :: Unity Ads init: load configuration from config.unityads.unity3d.com/webview/3.7.5/release/config.json

    2022/10/22 12:28:14.500 20386 20483 Info UnityAds com.unity3d.services.core.configuration.InitializeThread$InitializeStateLoadCache.execute() (line:346) :: Unity Ads init: webapp loaded from local cache

    2022/10/22 12:28:15.298 20386 20591 Warn UnityAds com.unity3d.services.core.connectivity.ConnectivityMonitor.connectionStatusChanged() (line:173) :: Unity Ads was not able to get current network type due to missing permission

    2022/10/22 12:28:15.458 20386 20577 Warn UnityAds com.unity3d.services.core.device.Device.getNetworkType() (line:135) :: Unity Ads was not able to get current network type due to missing permission
     

    Attached Files:

    Last edited: Oct 22, 2022
  2. Unity_Adamski

    Unity_Adamski

    Unity Technologies

    Joined:
    Jul 20, 2020
    Posts:
    110
    Hi, the above warning is a known issue on certain Android versions. It does not result in any issues displaying ads in your application. This can be suppressed by adding the READ_PHONE_STATE permission.
     
  3. Ohyouknow

    Ohyouknow

    Joined:
    Oct 23, 2013
    Posts:
    135
    Hi @ads-adam-unity , I placed that permission in my manifest, and "allowed" it on the device and still no ads in the APP. Ads work fine in the editor still, but when I press to watch an ad, nothing shows. My log cat doesnt show it needs a permission anymore, so thats a good sign, but an ad is not showing. Is there a specific Android version or Unity version/ads SDK that you know for sure works? Any ideas on what to try next? Heres what my log shows now:

    2022/10/24 17:16:05.771 32336 32431 Info UnityAds com.unity3d.services.UnityServices.initialize() (line:131) :: Initializing Unity Services 3.7.5 (3750) with game id XXXXXXX in production mode

    2022/10/24 17:16:05.776 32336 32431 Info UnityAds com.unity3d.services.UnityServices.initialize() (line:146) :: Unity Services environment check OK

    2022/10/24 17:16:07.189 32336 32636 Warn UnityAds com.unity3d.services.core.api.Sdk.logWarning() (line:78) :: {"message":"model: DeviceInfo key: openAdvertisingTrackingId with value: null: null is not in: string,undefined","name":"CheckValueError"}

    2022/10/24 17:06:18.222 28285 28392 Info UnityAds com.unity3d.services.core.configuration.InitializeThread$InitializeStateConfig.execute() (line:289) :: Unity Ads init: load configuration from https://config.unityads.unity3d.com/webview/3.7.5/release/config.json

    2022/10/24 17:06:18.567 28285 28392 Info UnityAds com.unity3d.services.core.configuration.InitializeThread$InitializeStateLoadCache.execute() (line:346) :: Unity Ads init: webapp loaded from local cache

    2022/10/24 17:06:18.179 28285 28327 Debug UnityAds com.unity3d.ads.UnityAds.initialize() (line:636) :: ENTERED METHOD

    2022/10/24 17:06:18.179 28285 28327 Debug UnityAds com.unity3d.services.ads.UnityAdsImplementation.initialize() (line:72) :: ENTERED METHOD

    2022/10/24 17:06:18.222 28285 28392 Info UnityAds com.unity3d.services.core.configuration.InitializeThread$InitializeStateConfig.execute() (line:289) :: Unity Ads init: load configuration from https://config.unityads.unity3d.com/webview/3.7.5/release/config.json

    2022/10/24 17:06:19.586 28285 28478 Info UnityAds com.unity3d.services.core.api.Sdk.logInfo() (line:84) :: Requesting configuration from publisher-config.unityads.unity3d.com/games/1130496/configuration?deviceMake=samsung&screenDensity=272&screenSize=268435795&idfi=82710530-ee5b-4ccb-93b9-7af9a7190f81&advertisingTrackingId=68ac415b-b4b1-4d0c-af67-0bd28088194f&limitAdTracking=false&installationId=

    2022/10/24 17:06:19.753 28285 28285 Info chromium [INFO:CONSOLE(0)] "Uncaught (in promise) [object Array]", source: file:///storage/emulated/0/Android/data/com.company.game/cache/UnityAdsCache/UnityAdsWebApp.html?platform=android&origin=https%3A%2F%2Fconfig.unityads.unity3d.com%2Fwebview%2F3.7.4%2F2780d594569a532efd8006059e1d8ea6e9d419d4%2Frelease%2Findex.html&version=2780d594569a532efd8006059e1d8ea6e9d419d4 (0)

    2022/10/24 17:06:19.792 28285 28478 Info UnityAds com.unity3d.services.core.api.Sdk.logInfo() (line:84) :: Requesting ad plan from https://auction.unityads.unity3d.co...Height=1200&connectionType=wifi&networkType=0
     
    Last edited: Oct 25, 2022
  4. Ohyouknow

    Ohyouknow

    Joined:
    Oct 23, 2013
    Posts:
    135
    @rasmus-unity any thoughts on this? I've implemented everything I could find in documentation/google regarding the manifest and still no ads in the build, but everything in the editor works. My game in google play works just fine as it is, but I need to put out an update and the new build isn't showing ads.
    Code (CSharp):
    1. ?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.unity3d.player" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
    3.   <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
    4.   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    5.   <uses-permission android:name="android.permission.INTERNET" />
    6.   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    7.   <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    8.   <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
    9.   <application android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
    10.     <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name">
    11.       <intent-filter>
    12.         <action android:name="android.intent.action.MAIN" />
    13.         <category android:name="android.intent.category.LAUNCHER" />
    14.       </intent-filter>
    15.       <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    16.     </activity>
    17.     <activity android:name="com.facebook.unity.FBUnityLoginActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    18.     <activity android:name="com.facebook.unity.FBUnityDialogsActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    19.     <activity android:name="com.facebook.unity.FBUnityAppLinkActivity" android:exported="true" />
    20.     <activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true" />
    21.     <activity android:name="com.facebook.unity.FBUnityGameRequestActivity" />
    22.     <activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />
    23.     <activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />
    24.     <activity android:name="com.facebook.unity.AppInviteDialogActivity" />
    25.     <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="GAMEID" />
    26.     <provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProviderGAMEID" android:exported="true" />
    27.     <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />
    28.   </application>
    29.   <application>
    30.         <activity
    31.             android:name="com.unity3d.ads.adunit.AdUnitActivity"
    32.             android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
    33.             android:hardwareAccelerated="true"
    34.             android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
    35.         <activity
    36.             android:name="com.unity3d.ads.adunit.AdUnitSoftwareActivity"
    37.             android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
    38.             android:hardwareAccelerated="false"
    39.             android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
    40.     </application>
    41. </manifest>
     
  5. Ohyouknow

    Ohyouknow

    Joined:
    Oct 23, 2013
    Posts:
    135
    Hi all, for what it's worth, my issues were not code related, permissions related, it was Unity Ads SDK related. I don't know what the issues are on Unity's end, but I tried numerous SDK's and the ones that worked for me was 3.6.1, 3.5.0.

    @LIU_Hanyang96 - @Kyle_unity - @ads-adam-unity - @JeffDUnity3D

    I even removed every permission from access network, internet, read phone state, and activities, and the ads still worked fine in my build when I downgraded to 3.6.1.

    Anything 4.0 and above does not work even with all the permissions granted. Will there be an update anytime soon for Android, as the deadline to update the ads SDK to their requirements start in Jan. This isn't a rare issue as I've seen numerous threads so the fix cant be to downgrade to an SDK GooglePlay will no longer accept.
     
  6. Unity_Adamski

    Unity_Adamski

    Unity Technologies

    Joined:
    Jul 20, 2020
    Posts:
    110
    Hi @Ohyouknow, looking at the logs you have shared I can't see anything wrong. The permissions error would not cause your ads to stop showing. Could you try updating to the latest version of the Unity Ads SDK and be sure that you are using the updated implementation as shown on our docs site.
    Also when updating your implementation you will be required to Load an ad every time before you show the ad. I would advise you do this in the OnInitializationComplete and in the OnUnityAdsShowComplete callbacks.
     
  7. Ohyouknow

    Ohyouknow

    Joined:
    Oct 23, 2013
    Posts:
    135
    Hi @ads-adam-unity could you please check your PM. I've sent you some of my scripts and info for help. Would love to get this figured out with you if possible!
     
  8. Ohyouknow

    Ohyouknow

    Joined:
    Oct 23, 2013
    Posts:
    135
    hi @ads-adam-unity - just checking in to see if you had any time to look over the last stuff I sent. Could really use your help