简体   繁体   中英

AdMob loads test ad but not real ad

I can load test ads but as soon as I change the app unit id to my own the error failed to load ad: 0 pops up

05-21 10:21:25.330 23856-23856/com.stickydata D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
05-21 10:21:25.908 23856-23856/com.stickydata D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
05-21 10:21:25.956 23856-23856/com.stickydata I/Ads: Starting ad request.
05-21 10:21:25.958 23856-23856/com.stickydata I/Ads: Use AdRequest.Builder.addTestDevice("1500304F0968173B289404F1774F9634") to get test ads on this device.
05-21 10:21:26.408 23856-23868/com.stickydata W/Ads: There was a problem getting an ad response. ErrorCode: 0
05-21 10:21:26.409 23856-23856/com.stickydata W/Ads: Failed to load ad: 0

The most common answer I found here is to wait some hours after creating the ad on the AdMob webpage, but I created the ad two days ago and still run into this error...

In MainActivity:

MobileAds.initialize(this, "ca-app-pub-************~********");

In fragment where the app is displayed:

    mAdView = (AdView) rootview.findViewById(adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    mAdView.setAdListener(new AdListener() {

In the fragment layout.xml:

 <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="ca-app-pub-9556*********/**********">
    </com.google.android.gms.ads.AdView>

Gradle dependencies:

 compile fileTree(include: ['*.jar'], dir: 'libs')
    compile fileTree(include: ['*.jar'], dir: 'app/libs')
    compile project(':AWSMobileHelper')
    compile 'com.android.support:customtabs:25.1.0'
    compile 'com.facebook.android:facebook-android-sdk:4.22.0'
    compile 'com.google.android.gms:play-services-auth:10.2.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.android.support:appcompat-v7:25.+'
    compile 'com.android.support:palette-v7:25.+'
    compile 'com.android.support:support-v4:25.+'
    compile 'com.android.support:recyclerview-v7:25.+'
    compile 'com.android.support:design:25.+'
    compile 'com.journeyapps:zxing-android-embedded:3.5.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.amazonaws:aws-android-sdk-core:2.3.9'
    compile 'com.amazonaws:aws-android-sdk-cognito:2.3.9'
    compile 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.3.9'
    compile 'com.amazonaws:aws-android-sdk-s3:2.3.+'
    compile 'com.amazonaws:aws-android-sdk-ddb:2.+'
    compile 'com.amazonaws:aws-android-sdk-ddb-mapper:2.+'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.getbase:floatingactionbutton:1.10.1'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'commons-io:commons-io:2.5'
    compile 'com.github.barteksc:pdfium-android:1.4.0'
    compile 'com.diegocarloslima:byakugallery:0.1.+@aar'
    compile 'com.google.android.gms:play-services-ads:10.2.6'

Any ideas?

UPDATE

When I change the build type to release the erro changes to:

05-21 10:42:41.778 3113-3113/? I/Ads: Starting ad request.
05-21 10:42:41.778 3113-3113/? I/Ads: Use AdRequest.Builder.addTestDevice("*********************") to get test ads on this device.
05-21 10:42:42.076 17256-3465/? W/Ads: Received error HTTP response code: 403
05-21 10:42:42.077 3113-3176/? W/Ads: There was a problem getting an ad response. ErrorCode: 0
05-21 10:42:42.087 3113-3113/? W/Ads: Failed to load ad: 0

I am testing the app on a moto g5.

UPDATE 2

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.stickydata">

    <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" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

    <uses-feature android:name="android.hardware.camera"
        android:required="true" />

    <uses-permission android:name="com.android.vending.BILLING" />


    <application
        android:name=".Application"
        android:allowBackup="true"
        android:icon="@drawable/sdlogo_simple"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name=".SplashActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:label="@string/app_name">
            <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/title_activity_main"
            android:launchMode="singleInstance" />
        <activity
            android:name=".util.DetailActivity"
            android:label="DetailActivity" />



        <!-- BEGIN - APP CONTENT DELIVERY AND USER DATA STORAGE -->
        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version"/>

        <!--
         The following services and receivers are used to deal with transfer of
         files. If you copy and paste the user data storage or app content delivery
         feature from this sample app into your own app, make sure you include
         these items, and customize the string identifiers they use in the strings
         XML resource file.
        -->

        <service
            android:name="com.amazonaws.mobileconnectors.s3.transferutility.TransferService"
            android:enabled="true" />
        <service android:name="com.amazonaws.mobile.downloader.service.DownloadService" />

        <receiver
            android:name="com.amazonaws.mobile.downloader.service.NetworkStateListener"
            android:enabled="false"
            android:exported="false">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
        </receiver>

        <provider
            android:name="com.amazonaws.mobile.downloader.query.DownloadQueueProvider"
            android:authorities="@string/download_queue_provider_authority"
            android:enabled="true"
            android:exported="false" />

        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="${applicationId}.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>

        <!-- END - APP CONTENT DELIVERY AND USER DATA STORAGE -->


        <!-- BEGIN - FACEBOOK SIGN-IN -->

        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="@string/fb_login_protocol_scheme" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />

        <!-- END - FACEBOOK SIGN-IN -->

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />


    </application>

</manifest>

I created the ad 3 days ago, I do not think that it should be a problem of waiting longer.

设置广告以加载实际广告需要24小时。

AdRequest.Builder.addTestDevice(" ") , used for testing purpose if it's fine over testing and not able to show Ad on live App, wait for a few hours.

According to Google :

"It could be that you have only recently created a new Ad Unit ID and requesting for live ads. It could take a few hours for ads to start getting served if that is that case. If you are receiving test ads then your implementation is fine. Just wait a few hours and see if you are able to receive live ads then. If not, can send us your Ad Unit ID for us to look into."

https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/fBe3YL3ffpo

After waiting some times/hours if still having problem then you need to cross check Ad unit Id and AppId from AdMob account.

事实证明我没有在我的Admob帐户中设置付款信息...

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM