android - 没有 firebase 的 AdMob 广告

标签 android admob

我想将 AdMob 广告集成到我的新 Android 项目中,但当应用程序尝试加载广告时出现错误。 获取广告响应时出现问题。ErrorCode:0无法加载广告:0。我不想集成 firebase

我将播放服务添加到我的 gradle 文件中:

dependencies {
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services:10.0.1'
}

这是我的 manifest.xml:

</application>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

这是我的 activity_main.xml:

xmlns:ads="http://schemas.android.com/apk/res-auto"

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

在我的代码中我添加了:

AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);

最佳答案

如果你去这里:https://developers.google.com/android/guides/setup您会找到所有可以使用的 Google Play 服务,包括广告。添加此依赖项:

dependencies {
    compile 'com.google.android.gms:play-services-ads:10.0.1'
}

关于android - 没有 firebase 的 AdMob 广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41510995/

相关文章:

android - 如何在 anko 中为按钮设置图标(可绘制)?

javascript - 使用 PhoneGap 从设备的图片库中选择多张照片

java - 在运行另一个 Runnable 之前等待 Runnable 完成

android - 什么是provideLayout()?.let { setContentView(it) }?

ios - 我是否需要在导航 Controller subview 中使用单例 GADRequest() ?

android - 它什么时候会在 Android 应用程序的 admob 上生效

android - 禁用方向更改 - WindowManager

android - 如何在我的手机/应用程序上测试 AdMob?

android - 显示图片时,Google Ads MediaView 无法正确地将高度调整为 wrap_content

java - 不幸的是应用程序停止了: AdMob Error?