Java Admob广告未加载
我在play store上有一个应用程序,最近我一直在考虑添加admob广告。因此,在他们批准我的个人资料后,我添加了“中间”广告。我按照程序操作,但广告不想显示,事实上,此日志显示在此处:Java Admob广告未加载,java,android,android-studio,admob,Java,Android,Android Studio,Admob,我在play store上有一个应用程序,最近我一直在考虑添加admob广告。因此,在他们批准我的个人资料后,我添加了“中间”广告。我按照程序操作,但广告不想显示,事实上,此日志显示在此处: The interstitial wasn't loaded yet. 我想试着解决这个问题,你能帮我吗?我将不胜感激!我将发布我的代码: 联系人活动中的Admob代码(mainactivity) 构建Gradle.app apply plugin: 'com.android.applicatio
The interstitial wasn't loaded yet.
我想试着解决这个问题,你能帮我吗?我将不胜感激!我将发布我的代码:
联系人活动中的Admob代码(mainactivity)
构建Gradle.app
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
defaultConfig {
applicationId "com.conta.ftof"
minSdkVersion 21
targetSdkVersion 29
versionCode 6
versionName "1.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0' // compreso
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'com.google.firebase:firebase-auth:19.4.0'
implementation 'com.google.firebase:firebase-database:19.5.0'
implementation 'com.google.firebase:firebase-core:17.5.1' // compreso
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
implementation 'com.hbb20:ccp:2.1.9'
implementation 'pub.devrel:easypermissions:0.4.0'
implementation 'com.android.support:percent:29.0.0'
implementation 'com.google.android.gms:play-services-ads:19.5.0'
implementation 'com.google.firebase:firebase-storage:19.2.0' //compreso
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0' //compreso
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'com.opentok.android:opentok-android-sdk:2.15.3'
implementation 'pub.devrel:easypermissions:0.4.0'
implementation 'com.squareup.picasso:picasso:2.71828'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-analytics:17.6.0'
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.conta.ftof">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".donate" />
<activity android:name=".VideoCallActivity" />
<activity android:name=".CallingActivity" />
<activity android:name=".ProfileActivity" />
<activity android:name=".FindPeopleActivity" />
<activity android:name=".NotificationsActivity" />
<activity android:name=".SettingsActivity" />
<activity
android:name=".ContactsActivity"
android:label="@string/title_activity_main" />
<activity android:name=".RegistrationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="xx-xxx-xxx-xxxxxxxxxxxxxxxxx~xxxxxxxxxx"/> //censored
<receiver android:name=".ReminderBroadcast"/>
</application>
</manifest>
//审查
如果您能帮助我,我会尽快将您作为解决方案参考此@NadeemShaikh,我尽量等到明天。奇怪的是,admob小组告诉我有32个广告请求,即使它们没有load@NadeemShaikh广告仍然不起作用,我想在这一点上我的代码有问题。你能帮我找到错误吗?你试过测试广告了吗?@NadeemShaikh是的,它不加载相同的内容
@Override
protected void onCreate(Bundle savedInstanceState) {
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});
//
Boolean isFirstRun = getSharedPreferences("PREFERENCE", MODE_PRIVATE)
.getBoolean("isFirstRun", true);
if (isFirstRun) {
//show start activity
startActivity(new Intent(ContactsActivity.this, SettingsActivity.class));
}
getSharedPreferences("PREFERENCE", MODE_PRIVATE).edit()
.putBoolean("isFirstRun", false).commit();
//
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contacts);
MobileAds.initialize(this,
"xx-xxx-xxx-xxxxxxxxxxxxxxxxx~xxxxxxxxxx"); //censored
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("xx-xxx-xxx-xxxxxxxxxxxxxx/xxxxxxxxxxx"); //censored
mInterstitialAd.loadAd(new AdRequest.Builder().build());
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
else{
Log.d("TAG", "The interstitial wasn't loaded yet.");
}