Admob ad错误代码:0。Everithyng已更新并经过精心设计,但未显示广告

时间:2016-07-31 11:58:43

标签: android admob

以下是我的错误代码:

07-31 13:37:47.413 31965-31965/corvusbyte.neverboredlite I/dalvikvm: Could not find method android.security.NetworkSecurityPolicy.getInstance, referenced from method com.google.android.gms.ads.internal.state.h.a
07-31 13:37:47.522 31965-31965/corvusbyte.neverboredlite D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
07-31 13:37:47.530 31965-31965/corvusbyte.neverboredlite I/dalvikvm: Could not find method android.security.NetworkSecurityPolicy.getInstance, referenced from method com.google.android.gms.ads.internal.state.h.a
07-31 13:37:47.544 31965-31965/corvusbyte.neverboredlite D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
07-31 13:37:47.620 31965-31965/corvusbyte.neverboredlite I/Ads: Starting ad request.
07-31 13:37:47.810 31965-31977/corvusbyte.neverboredlite D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x63a2fa50
07-31 13:37:53.071 31965-31978/corvusbyte.neverboredlite D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x63a34d80
07-31 13:37:58.169 31965-31977/corvusbyte.neverboredlite W/Ads: There was a problem getting an ad response. ErrorCode: 0
07-31 13:37:58.171 31965-31965/corvusbyte.neverboredlite W/Ads: Failed to load ad: 0
07-31 13:38:03.175 31965-31978/corvusbyte.neverboredlite D/IPCThreadState: [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x64331428
07-31 13:39:18.091 31965-31965/corvusbyte.neverboredlite D/ActivityThread: BDC-Calling onReceive: intent=Intent { act=android.intent.action.SCREEN_OFF flg=0x50000010 }, ordered=true, receiver=com.google.android.gms.ads.internal.util.ac@4214bf40, IIntentReceiver=4214bf88

我的xml(广告部分):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:ads="http://schemas.android.com/apk/res-auto">

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView_main"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="@string/main_ad_unit_id">
    </com.google.android.gms.ads.AdView>

我的java(部分内容):

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;


public class MainActivity extends AppCompatActivity {

    private AdView mAdView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        MobileAds.initialize(getApplicationContext(), "app_id");
        mAdView = (AdView) findViewById(R.id.adView_main);
        AdRequest adRequest = new AdRequest.Builder()
                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                .addTestDevice("85FB65B00143337DE5FE7492DF14F269")
                .build();
        mAdView.loadAd(adRequest);
    }

我的清单:

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

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:largeHeap="true">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".ResultsActivity">
            <intent-filter>
                <action android:name="corvusbyte.neverboredlite.RESULTS"/>

                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
        <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>

</manifest>

我的gradle文件(部分内容): 模块

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.google.firebase:firebase-ads:9.2.1'
}
apply plugin: 'com.google.gms.google-services'

项目

dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.google.gms:google-services:3.0.0'

我的问题是没有广告显示。我的布局顶部只有一个空白区域。我有最新的SDK工具,Google Play资源等... 请帮帮我!

1 个答案:

答案 0 :(得分:2)

正如您在评论中所说,您使用了translatable= "false"的属性。尝试删除它,然后运行应用程序。它可以通过代码访问,最终会出现广告。