MANIFEST
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hightimes.fourtwenty">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="4:20"
android:theme="@style/AppTheme" >
<!--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=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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"
android:theme="@android:style/Theme.Translucent" />
</application>
java
MobileAds.initialize(this,"@string/banner_app_id");
mAdView = (AdView) findViewById(R.id.myAdView);
AdRequest adRequest = new AdRequest.Builder()
.build();
mAdView.loadAd(adRequest);
layout file
<com.google.android.gms.ads.AdView
android:id="@+id/myAdView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"
/>
Gradle script file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile 'com.android.support:design:23.4.0'
}
apply plugin: 'com.google.gms.google-services'
The test ad loads fine using android studio, the live google play ad is not showing at all on different test devices and locations. I linked the ad inside the admob app management page and it shows as 1 Active ad. I am using the admob generated appID and adunitID and I also included the google-services.json file.The only thing I could think of is that it either takes a few days for the ads to populate or that my app displays drug related material and it has +18 ratings, but I never received a notice from admob nor do I see anything like account suspended. Thanks for any help in advanced!
MobileAds.initialize(this,"@string/banner_app_id");
You are passing the string "@string/banner_app_id" as the Application ID.
To find the application ID corresponding to your application, click the App management option under the settings drop-down (located in the upper right hand corner) on the AdMob account page. Application IDs have the form ca-app-pub-XXXXXXXXXXXXXXXX~NNNNNNNNNN.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.