1

这是我对统一广告的初始化

mAdView = findViewById(R.id.adView);
UnityAds.initialize(this, RentC.getApp().GAMEID, null, RentC.getApp().isTestMode, true);
BannerView mBannerView = new BannerView(this, adUnitId, new UnityBannerSize(320, 50));
mAdView.addView(mBannerView);
mBannerView.load();

广告未显示,并且在 logcat 中我得到了

2021-08-06 21:54:23.844 25057-25206/com.yrrappz.rent_c W/UnityAds: com.unity3d.services.core.connectivity.ConnectivityMonitor.initConnectionStatus() (line:109) :: Unity Ads was not able to get current network type due to missing permission
2021-08-06 21:54:23.855 25057-25206/com.yrrappz.rent_c I/UnityAds: com.unity3d.services.core.api.Sdk.logInfo() (line:84) :: mediation detection is:{"UnityEngine":false}
2021-08-06 21:54:23.859 25057-25209/com.yrrappz.rent_c W/UnityAds: com.unity3d.services.core.connectivity.ConnectivityMonitor.connectionStatusChanged() (line:173) :: Unity Ads was not able to get current network type due to missing permission
2021-08-06 21:54:23.863 25057-25209/com.yrrappz.rent_c W/UnityAds: com.unity3d.services.core.connectivity.ConnectivityMonitor.connectionStatusChanged() (line:173) :: Unity Ads was not able to get current network type due to missing permission

给定的权限

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

你能帮我摆脱这个吗

4

1 回答 1

1

要扩展我的评论,您缺少所需的网络权限。要启用它,请执行以下步骤:

转到编辑-> 项目设置-> 播放器。选择 Android,构建设置,将 Internet Access 从Auto更改为Require

如果您使用的是自定义 gradle,则需要手动添加权限。他们应该是:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
于 2021-08-06T19:51:35.473 回答