Admob在调试模式下在我的应用程序上停止了广告,我的代码是否有问题?

时间:2019-05-25 21:15:01

标签: java android admob ads

几天前,AdMob广告在我的调试应用中展示了。但是,现在仅显示测试广告。有什么理由吗?

P.S。我对AdMob并不陌生,也没有收到有关在调试模式下使用真实广告的任何通知。

我检查了一次又一次的代码,但是没有错。我还回到了(实施说明)

https://developers.google.com/admob/android/quick-start?hl=en-US#import_the_mobile_ads_sdk

从“我的(Androidmanifest)”开始

<application

    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="@string/app_ad_id"/>

application/>

第二(内部版本:Module.app)

 allprojects {
repositories {

    google()

    jcenter()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }

}

第三(布局:a_main)

 <ScrollView
       xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:app="http://schemas.android.com/apk/res-auto"
       xmlns:tools="http://schemas.android.com/tools"
       android:id="@+id/scrollview_tv"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:fillViewport="true">

  <android.support.constraint.ConstraintLayout
       android:id="@+id/main_r"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:background="#16010101"
       tools:context=".MainActivity">

    <RelativeLayout
        android:id="@+id/adView_test"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

  </android.support.constraint.ConstraintLayout>

</ScrollView>

最后的活动(MainActivity)

  public class MainActivity extends AppCompatActivity {

    private AdView adView;
    private AdRequest adRequest;


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

    MobileAds.initialize(this, getString(R.string.app_ad_id));
    admobCall();

  }

 // Function to Set Ads for Main Layout
 private void admobCall(){

    View adContainer = findViewById(R.id.adView_test);
    adView = new AdView(this);
    adView.setAdSize(AdSize.SMART_BANNER);

    //Real Admob Main Activity Banner
     adView.setAdUnitId(getString(R.string.main_ad_id));

    // Test google ID for Banner
    // adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");

    ((RelativeLayout)adContainer).addView(adView);

    // This Request will bulid the ADs as a Test
    //adRequest = new   AdRequest.Builder()
    //.addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();

    // This Request Will bulid the ADs as Real
    adRequest = new AdRequest.Builder().build();

    adView.loadAd(adRequest);

}

在Logct中没有什么可提供的:

 I/Ads: Ad failed to load : 3

 I/Ads: Use AdRequest.Builder.addTestDevice(".....") to get test ads on this device.

最后一个问题,我不知道这是否是问题,我正在使用华为手机进行调试。

AdMob自从华为BAN成为Google的一部分以来受到影响吗?

0 个答案:

没有答案