应用中的AdMob没有显示

时间:2016-04-17 14:38:15

标签: android admob

我想在Android应用中展示一个简单的测试广告。我正在使用这个github项目来测试

https://github.com/googleads/googleads-mobile-android-examples/tree/master/admob/BannerExample

我也经历了这个例子https://developers.google.com/admob/android/quick-start#configure_gradle

我使用的是IntelliJ而不是Android Studio,因此无法完全遵循它。

我的问题是广告似乎没有出现。日志在下面,我添加了几个**旁边的线,我认为可能有问题。我还添加了我的代码。我没有在清单文件中添加任何内容(我没有看到任何我需要的例子)

我正在使用模拟器。对我可以使用的模拟器有什么限制吗?目前,我从未看到广告应该是广告或任何占位符。

任何帮助非常感谢。 感谢

CODE

布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin"
            android:paddingBottom="@dimen/activity_vertical_margin"
            tools:context=".EntryPoint">

  <TextView android:text="@string/hello_world" android:layout_width="wrap_content"
          android:layout_height="wrap_content" />

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

</RelativeLayout>

代码

 private AdView mAdView;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_my);
     mAdView = (AdView) findViewById(R.id.ad_view);
     AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .build();
     mAdView.loadAd(adRequest);
 }

 /** Called when leaving the activity */
 @Override
 public void onPause() {
    if (mAdView != null) {
        mAdView.pause();
    }
    super.onPause();
 }

 /** Called when returning to the activity */
 @Override
 public void onResume() {
    super.onResume();
    if (mAdView != null) {
        mAdView.resume();
    }
 }

 /** Called before the activity is destroyed */
 @Override
 public void onDestroy() {
    if (mAdView != null) {
        mAdView.destroy();
    }
    super.onDestroy();
 }

日志

 5222-5222/? I/art﹕ Not late-enabling -Xcheck:jni (already on)
 5222-5222/? I/art﹕ Late-enabling JIT
 5222-5222/? I/art﹕ JIT created with code_cache_capacity=2MB compile_threshold=1000
 ** 5222-5222/my.app W/System﹕ ClassLoader referenced unknown path: /data/app/my.app-2/lib/arm
 ** 5222-5222/my.app W/GooglePlayServicesUtil﹕ Google Play services is missing.
 5222-5222/my.app I/WebViewFactory﹕ Loading com.android.webview version 44.0.2403.119 (code 246011900)
 5222-5222/my.app W/System﹕ ClassLoader referenced unknown path: /system/app/webview/lib/arm
 5222-5222/my.app I/LibraryLoader﹕ Time to load native libraries: 44 ms (timestamps 1048-1092)
 5222-5222/my.app I/LibraryLoader﹕ Expected native library version number "",actual native library version number ""
 5222-5250/my.app W/art﹕ Long monitor contention event with owner method=void java.lang.Thread.nativeCreate(java.lang.Thread, long, boolean) from Thread.java:4294967294 waiters=0 for 206ms
 5222-5231/my.app W/art﹕ Suspending all threads took: 91.755ms
 5222-5222/my.app V/WebViewChromiumFactoryProvider﹕ Binding Chromium to main looper Looper (main, tid 1) {84fa4d0}
 5222-5222/my.app I/LibraryLoader﹕ Expected native library version number "",actual native library version number ""
 5222-5222/my.app I/chromium﹕ [INFO:library_loader_hooks.cc(120)] Chromium logging enabled: level = 0, default verbosity = 0
 5222-5222/my.app I/BrowserStartupController﹕ Initializing chromium process, singleProcess=true
 5222-5222/my.app W/art﹕ Attempt to remove non-JNI local reference, dumping thread
 5222-5222/my.app E/SysUtils﹕ ApplicationContext is null in ApplicationStatus
 5222-5222/my.app W/chromium﹕ [WARNING:resource_bundle.cc(285)] locale_file_path.empty()
 ** 5222-5222/my.app E/libEGL﹕ validate_display:255 error 3008 (EGL_BAD_DISPLAY)
 ** 5222-5222/my.app E/libEGL﹕ validate_display:255 error 3008 (EGL_BAD_DISPLAY)
 **   5222-5222/my.app E/chromium﹕ [ERROR:gl_surface_egl.cc(327)] No suitable EGL configs found.
 **  5222-5222/my.app E/chromium﹕ [ERROR:gl_surface_android.cc(23)] GLSurfaceEGL::InitializeOneOff failed.
 5222-5222/my.app E/chromium﹕ [ERROR:browser_main_loop.cc(698)] GLSurface::InitializeOneOff failed
 5222-5250/my.app W/art﹕ Long monitor contention event with owner method=void android.app.SharedPreferencesImpl$1.run() from SharedPreferencesImpl.java:90 waiters=1 for 280ms
 5222-5247/my.app W/art﹕ Long monitor contention event with owner method=void java.lang.Thread.nativeCreate(java.lang.Thread, long, boolean) from Thread.java:4294967294 waiters=3 for 441ms
 5222-5231/my.app W/art﹕ Suspending all threads took: 16.275ms
 5222-5222/my.app E/DataReductionProxySettingListener﹕ No DRP key due to exception:java.lang.ClassNotFoundException: com.android.webview.chromium.Drp
 5222-5269/my.app W/AudioManagerAndroid﹕ Requires BLUETOOTH permission
 ** 5222-5222/my.app I/Ads﹕ Starting ad request.
 5222-5231/my.app W/art﹕ Suspending all threads took: 9.629ms
 5222-5222/my.app I/Choreographer﹕ Skipped 41 frames!  The application may be doing too much work on its main thread.
 5222-5222/my.app D/gralloc_goldfish﹕ Emulator without GPU emulation detected.
 5222-5231/my.app W/art﹕ Suspending all threads took: 140.144ms
 ** 5222-5246/my.app W/GooglePlayServicesUtil﹕ Google Play services is missing.
 ** 5222-5246/my.app W/GooglePlayServicesUtil﹕ Google Play services is missing.
 5222-5267/my.app W/chromium﹕ [WARNING:data_reduction_proxy_config.cc(423)] SPDY proxy OFF at startup
 5222-5222/my.app W/art﹕ Attempt to remove non-JNI local reference, dumping thread
 5222-5222/my.app W/AwContents﹕ onDetachedFromWindow called when already detached. Ignoring
 5222-5222/my.app W/art﹕ Attempt to remove non-JNI local reference, dumping thread
 5222-5222/my.app W/art﹕ Attempt to remove non-JNI local reference, dumping thread
 5222-5303/my.app A/chromium﹕ [FATAL:gl_surface_android.cc(58)] Check failed: kGLImplementationNone != GetGLImplementation() (0 vs. 0)
 5222-5303/my.app W/google-breakpad﹕ ### ### ### ### ### ### ### ### ### ### ### ### ###
 5222-5303/my.app W/google-breakpad﹕ Chrome build fingerprint:
 5222-5303/my.app W/google-breakpad﹕ 1.04
 5222-5303/my.app W/google-breakpad﹕ 5
 5222-5303/my.app W/google-breakpad﹕ 023f32a1-4862-425f-a49b-e5b1792614ed
 5222-5303/my.app W/google-breakpad﹕ ### ### ### ### ### ### ### ### ### ### ### ### ###
 5222-5303/my.app E/chromium﹕ ### WebView Version 44.0.2403.119 (code 246011900)
 5222-5303/my.app A/libc﹕ Fatal signal 6 (SIGABRT), code -6 in tid 5303 (GpuThread)

由于

1 个答案:

答案 0 :(得分:1)

创建针对Google API的模拟器,而不是Android。