[英]Admob Ads don't load after updating to 'com.google.android.gms:play-services-ads:17.1.2'
I recently updated the 'com.google.android.gms:play-services-ads' dependendcies to 17.1.2 and my admob Ads won't load anymore. 我最近将'com.google.android.gms:play-services-ads'的依赖关系更新为17.1.2,并且我的admob广告将不再加载。 I used version 11 for a very long time and never had any issues but after updating they won't show anymore. 我使用版本11的时间很长,并且从未出现任何问题,但是更新后它们不再显示。
After I looked at the documentaion I realized that you have to initialize the APP-ID in the Launch activity and in the Manifest, so I adjusted my code but the Ads still don't show so I tried Admobs test Ad ids and they load fine. 在查看了文档之后,我意识到您必须在Launch活动和清单中初始化APP-ID,因此我调整了代码,但广告仍然没有显示,因此我尝试了Admobs测试广告ID,并且它们可以正常加载。
So the problem can't be in the implemntation of admob right? 因此,问题不能出在admob的隐含权利上吗?
Here my build.gradle 这是我的build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.25.4'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
signingConfigs {
config {
keyAlias 'XX'
keyPassword 'XX'
storeFile file('XX')
storePassword 'XX'
}
lintOptions {
checkReleaseBuilds false
}
}
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "XX"
minSdkVersion 17
targetSdkVersion 28
versionCode XX
versionName "XX"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
signingConfig signingConfigs.config
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
// https://mvnrepository.com/artifact/com.android.support/customtabs
implementation group: 'com.android.support', name: 'customtabs', version: '28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
implementation 'com.google.firebase:firebase-ads:17.1.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.android.billingclient:billing:1.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.8'
implementation 'com.google.firebase:firebase-database:16.0.6'
}
apply plugin: 'com.google.gms.google-services'
Here a snippet of the Manifest 这是清单的一小段
<?xml version="1.0" encoding="utf-8"?>
<!-- Include required permissions for Google Mobile Ads to run. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission. WAKE_LOCK" />
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/appicon1"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar"
>
<!-- This meta-data tag is required to use Google Play Services. -->
<meta-data
android:name="com.google.android.gms.version"
android:value=
"@integer/google_play_services_version" />
<activity android:name=".Splashscreen"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Include the AdActivity configChanges and theme. -->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
/>
<uses-library android:name="org.apache.http.legacy" android:required="false" />
<meta-data
android:name="io.fabric.ApiKey"
android:value="XXX" />
<!-- Sa+mple AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="@string/google_app_id"
/>
</application>
My Strings.xml 我的Strings.xml
<string name="ad_unit_id" translatable="false">ca-app-pub-XXX/XX</string>
<string name="google_app_id" translatable="false">ca-app-pub-XXX~XX</string>
<string name="banner_ad_unit_id" translatable="false">ca-app-pub-XXX/XX</string>
<string name="reward_id" translatable="false">ca-app-pub-XXX/XX</string>
Snippet of MAinactivity.class MAinactivity.class的片段
public AdView mAdView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this, getString(R.string.google_app_id));
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
So looking at the code I really can't see a reason the ads won't load. 因此,查看代码,我真的看不到广告无法加载的原因。 Is there anything else you have to consider when upgrading dependencies in regard to admob ads? 升级对admob广告的依赖关系时,您还需要考虑什么?
I had the similar issue - test ads work, but my own don't. 我遇到了类似的问题-测试广告有效,但我却没有。 I read somewhere that they won't load everytime you open your app, and that it takes few hours for them to show up after you add them to your app. 我读过某个地方,他们不会在您每次打开应用程序时加载,并且将它们添加到您的应用程序中需要几个小时才能显示出来。 Just go on Google AdMob console, and see impressions number - if it's not zero - they showed up on someone's phone. 只需在Google AdMob控制台上查看展示次数(如果不是零),它们就会显示在某人的手机上。
Did you update your app version on Google Play? 您是否在Google Play上更新了应用版本? If you haven't, do it. 如果还没有,那就去做。 That way you can test Google AdMob console solution, or let me know the name of the app, so I can check if I see ads myself. 这样,您可以测试Google AdMob控制台解决方案,或者让我知道应用程序的名称,以便检查自己是否看到广告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.