【问题标题】:Google Play Services AdMob Ads not displayingGoogle Play 服务 AdMob 广告未显示
【发布时间】:2014-07-10 04:32:48
【问题描述】:

我开发了一个 Android 应用程序,允许玩家观看广告以获取代币。我决定集成 AdMob。好吧,它是集成的,经过 11 个小时的搜索和阅读堆栈上的所有问题、教程和示例以及阅读 API,我遇到了没有广告显示的问题。我读过广告最多可能需要 3 个小时,但我认为 9 个小时后我应该得到一些东西。我已经研究了我的 logcat 中的所有错误,并且我发现的大多数信息都说“忽略这些”、“这是一个错误,谷歌说忽略”、“admob 不是传递你的广告”,以及所有这些问题似乎违背了使用此服务或任何可用广告服务的目的。下面是我实现admob + logcat的全部代码。

活动:

public class WatchForAds extends Activity {
    // private InterstitialAd mInterstitial;

     LinearLayout linearLayoutAds;

     String AD_UNIT_ID = "XXXXXXXXXXXXXXXXXXXXXX";

      private AdView mAdView;

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

     linearLayoutAds=(LinearLayout)findViewById(R.id.layoutMain);

        final AdView adView = new AdView(WatchForAds.this);
        adView.setAdUnitId(AD_UNIT_ID);
        adView.setAdSize(AdSize.BANNER);
        linearLayoutAds.addView(adView);

        final AdRequest.Builder adReq = new AdRequest.Builder();
        final AdRequest adRequest = adReq.build();
        adView.loadAd(adRequest);

    }
}

布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:orientation="vertical"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:id="@+id/layoutMain"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

    </LinearLayout>

</LinearLayout>

清单:

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/picturethis_logo"
        android:label="@string/app_name"
        android:logo="@drawable/picturethis_logo"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name="com.blubyrd.picturethispro.MainActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="sign_in.SignIn"
            android:label="@string/title_activity_sign_in" >
        </activity>
        <activity
            android:name="com.blubyrd.picturethispro.ChoosePlayType"
            android:label="@string/title_activity_choose_play_type" >
        </activity>
        <activity
            android:name="searchFriends.SearchFriends"
            android:label="@string/title_activity_search_friends" >
        </activity>
        <activity
            android:name="com.blubyrd.picturethispro.PlayMain"
            android:label="@string/title_activity_play_main" >
        </activity>
        <activity
            android:name="stage.PlayStage"
            android:label="@string/title_activity_play_stage" >
        </activity>
        <activity
            android:name="players.Players"
            android:label="@string/title_activity_players" >
        </activity>
        <activity
            android:name="createAccount.CreateAccount"
            android:label="@string/title_activity_create_account" >
        </activity>
        <activity
            android:name="myAccount.MyAccount"
            android:label="@string/title_activity_my_account" >
        </activity>
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
        <activity
            android:name="ads.WatchForAds"
            android:label="@string/title_activity_watch_for_ads" >
        </activity>
    </application>

</manifest>

proguard-project.txt:

-keep class * extends java.util.ListResourceBundle 
{    
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable 
{    
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * 
{    
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable 
{    
public static final ** CREATOR;
}

Google Play 服务:

google-play-services_lib.jar has been added as library and appears in the Android Dependencies Package

google-play-services.jar appears under Android Private Libraries

LogCat:

07-09 23:30:46.985: E/GooglePlayServicesUtil(5544): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
07-09 23:30:47.005: I/Ads(5544): Starting ad request.
07-09 23:30:47.010: I/Ads(5544): Use AdRequest.Builder.addTestDevice("A4847B337634DBF8A552C5386C756C83") to get test ads on this device.
07-09 23:30:47.015: I/Ads(5544): Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.
07-09 23:30:47.030: E/GooglePlayServicesUtil(5544): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
07-09 23:30:47.120: E/GooglePlayServicesUtil(5544): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
07-09 23:30:47.125: E/GooglePlayServicesUtil(5544): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
07-09 23:30:47.615: I/System.out(5544): SIGNED OUT
07-09 23:30:47.785: I/Ads(5544): No fill from ad server.
07-09 23:30:47.785: W/Ads(5544): Failed to load ad: 3

【问题讨论】:

  • 您是否尝试过使用日志中提到的AdRequest.Builder.addTestDevice("A4847B337634DBF8A552C5386C756C83") 获取测试广告?如果测试广告出现,那么一切都与配置后端(网页)有关。
  • 我没有尝试过测试广告,但尝试过插页式广告,但没有问题。不过我会尝试测试广告。
  • 我可以获得测试广告。我不确定我需要在 AdMob 中配置什么。我确实注册并添加了其他广告服务,但仅此而已。
  • 罗梅罗说的没错。我刚刚创建了一个新的广告单元并选择了横幅,一切正常。我想我不应该整天坐在那个广告单元上。哈哈。

标签: android admob google-play-services


【解决方案1】:

您必须导入 Google Play 服务库!

Setting Up Google Play Services

【讨论】:

    【解决方案2】:

    奖励观看广告的用户是 100% 违反 Admob 政策的。 您的帐户可能会被禁止。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多