我正在尝试在android中显示智能尺寸横幅,但广告没有展示,当我看到日志时显示:int cacheAmount = 256;
GameObject[] cache=new GameObject[cacheAmount];
int nextObjectIndex=0;
void CreateCache()
{
for (int i = 0; i < cacheAmount; i++)
{
cache[i] = (GameObject)Instantiate(projectile);
}
}
GameObject GetFromCache()
{
GameObject nextObject=cache[nextObjectIndex];
nextObjectIndedx++;
if (nextObjectIndex>=cacheAmount) nextObjectIndex=0;
return nextObject;
}
。
我在互联网上进行搜索,发现该问题是由于互联网连接引起的,但是我的手机上存在活动且可靠的网络连接。
以下是我的I/Ads: Ad failed to load : 2
gradle:
app
以下是我的活动课:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha3'
implementation 'com.android.support:support-v4:28.0.0'
testCompile 'junit:junit:4.12'
implementation 'com.airbnb.android:lottie:2.1.0'
implementation 'com.mikhaellopez:circularimageview:3.2.0'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
}
这是布局:
MobileAds.initialize(this, Utils.ADMOB_APP_ID);
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().addTestDevice("B2DD8C77E01892E0FF2A672FC77E2FF9").build();
mAdView.loadAd(adRequest);
这是与广告有关的一些错误日志:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/app_admob_id">
</com.google.android.gms.ads.AdView>
答案 0 :(得分:0)
当没有Internet连接时,最经常发生此问题。