2015-03-13 7 views
3

Я не могу решить проблему второго дня. Баннер AdMob не отображается. Работа в Android Studio. Скопировано Android Quick Start (все обновления загружены). Помоги пожалуйста.AdMob Banners и GLSurfaceview

OnCreate() метод:

public void onCreate(Bundle savedInstanceState) 
     { 
      super.onCreate(savedInstanceState); 
      requestWindowFeature(Window.FEATURE_NO_TITLE); 
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
        WindowManager.LayoutParams.FLAG_FULLSCREEN); 


      setContentView (R.layout.activity_main); 
      glView = (GLSurfaceView) this.findViewById (R.id.glSurface); 
    // 
      //glView = new GLSurfaceView(this); 
      glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); // crutch 
      glView.setRenderer(this); 
    //  //setContentView(glView); 

      glGraphics = new GLGraphics(glView); 
      fileIO = new AndroidFileIO(getAssets()); 
      audio = new AndroidAudio(this); 
      input = new AndroidInput(this, glView, 1, 1); 
      PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE); 
      wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "GLGame"); 


      AdView mAdView = (AdView) findViewById(R.id.adView); 
      AdRequest adRequest = new AdRequest.Builder() 
        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
        .addTestDevice("0CE08511E868CB06C13E5CB25A4F1C82").build(); 
      mAdView.loadAd(adRequest); 
     } 

манифеста

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

    <uses-permission android:name="android.permission.WAKE_LOCK" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
    <uses-sdk 
     android:minSdkVersion="9" 
     android:targetSdkVersion="18" /> 



    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 


     <activity 
      android:name=".TheColorsGame" 
      android:label="@string/app_name" 
      android:screenOrientation="portrait" 
      android:configChanges="orientation|keyboard|keyboardHidden"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

     !--Include the AdActivity configChanges and theme. --> 
     <activity android:name="com.google.android.gms.ads.AdActivity" 
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" 
        android:theme="@android:style/Theme.Translucent" /> 

     <!--This meta-data tag is required to use Google Play Services.--> 
     <meta-data android:name="com.google.android.gms.version" 
        android:value="@integer/google_play_services_version" /> 

    </application> 


    <!-- Include required permissions for Google Mobile Ads to run--> 
    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 

</manifest> 

activity_main

<?xml version="1.0" encoding="utf-8"?> 
    <FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <android.opengl.GLSurfaceView 
    android:id="@+id/glSurface" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="top|left" /> 

    <com.google.android.gms.ads.AdView 
    android:id="@+id/adView" 
    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> 

    </FrameLayout> 

LogCat

03-13 22:22:28.350 12680-12723/com.thecolors I/AndroidRuntime﹕ VM exiting with result code 0, cleanup skipped. 
03-13 22:23:25.530 17333-17333/com.thecolors D/dalvikvm﹕ Late-enabling CheckJNI 
03-13 22:23:25.690 17333-17357/com.thecolors V/SoundPoolThread﹕ beginThread 
03-13 22:23:25.690 17333-17357/com.thecolors V/SoundPoolThread﹕ run 
03-13 22:23:25.715 17333-17333/com.thecolors E/SensorManager﹕ thread start 
03-13 22:23:25.725 17333-17333/com.thecolors D/SensorManager﹕ registerListener :: handle = 0 name= LSM330DLC 3-axis Accelerometer delay= 20000 Listener= [email protected] 
03-13 22:23:25.790 17333-17333/com.thecolors D/dalvikvm﹕ GC_FOR_ALLOC freed 148K, 9% free 12426K/13511K, paused 33ms, total 33ms 
03-13 22:23:25.830 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 20K, 8% free 12460K/13511K, paused 13ms+13ms, total 40ms 
03-13 22:23:25.900 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 151K, 8% free 12844K/13959K, paused 11ms+6ms, total 31ms 
03-13 22:23:25.945 17333-17333/com.thecolors I/dalvikvm﹕ Could not find method android.webkit.WebSettings.getDefaultUserAgent, referenced from method com.google.android.gms.ads.internal.util.g.a 
03-13 22:23:25.945 17333-17333/com.thecolors W/dalvikvm﹕ VFY: unable to resolve static method 3097: Landroid/webkit/WebSettings;.getDefaultUserAgent (Landroid/content/Context;)Ljava/lang/String; 
03-13 22:23:25.945 17333-17333/com.thecolors D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0011 
03-13 22:23:26.030 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 214K, 9% free 13107K/14279K, paused 14ms+12ms, total 46ms 
03-13 22:23:26.050 17333-17333/com.thecolors I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.ew.c 
03-13 22:23:26.050 17333-17333/com.thecolors W/dalvikvm﹕ VFY: unable to resolve virtual method 441: Landroid/content/pm/PackageManager;.getPackageInstaller()Landroid/content/pm/PackageInstaller; 
03-13 22:23:26.050 17333-17333/com.thecolors D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000f 
03-13 22:23:26.060 17333-17376/com.thecolors D/dalvikvm﹕ DexOpt: --- BEGIN 'ads2130424813.jar' (bootstrap=0) --- 
03-13 22:23:26.210 17333-17333/com.thecolors I/webclipboard﹕ clipservice: [email protected] 
03-13 22:23:26.235 17333-17376/com.thecolors D/dalvikvm﹕ DexOpt: --- END 'ads2130424813.jar' (success) --- 
03-13 22:23:26.235 17333-17376/com.thecolors D/dalvikvm﹕ DEX prep '/data/data/com.thecolors/cache/ads2130424813.jar': unzip in 0ms, rewrite 176ms 
03-13 22:23:26.435 17333-17333/com.thecolors I/Ads﹕ Starting ad request. 
03-13 22:23:26.435 17333-17393/com.thecolors V/webkit﹕ BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {42d7e080} 
03-13 22:23:26.475 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 369K, 10% free 13205K/14535K, paused 2ms+12ms, total 48ms 
03-13 22:23:26.585 17333-17333/com.thecolors D/libEGL﹕ loaded /system/lib/egl/libEGL_mali.so 
03-13 22:23:26.595 17333-17333/com.thecolors D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_mali.so 
03-13 22:23:26.595 17333-17333/com.thecolors D/libEGL﹕ loaded /system/lib/egl/libGLESv2_mali.so 
03-13 22:23:26.600 17333-17333/com.thecolors D/﹕ Device driver API match 
    Device driver API version: 10 
    User space API version: 10 
03-13 22:23:26.600 17333-17333/com.thecolors D/﹕ mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Tue Oct 16 15:37:13 KST 2012 
03-13 22:23:26.655 17333-17333/com.thecolors D/OpenGLRenderer﹕ Enabling debug mode 0 
03-13 22:23:26.780 17333-17355/com.thecolors D/dalvikvm﹕ GC_FOR_ALLOC freed 53K, 9% free 13257K/14535K, paused 25ms, total 25ms 
03-13 22:23:26.805 17333-17355/com.thecolors I/dalvikvm-heap﹕ Grow heap (frag case) to 21.861MB for 8388624-byte allocation 
03-13 22:23:26.840 17333-17333/com.thecolors D/dalvikvm﹕ GC_FOR_ALLOC freed <1K, 6% free 21448K/22791K, paused 31ms, total 31ms 
03-13 22:23:26.880 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed <1K, 6% free 21453K/22791K, paused 12ms+2ms, total 38ms 
03-13 22:23:29.080 17333-17404/com.thecolors I/Ads﹕ No fill from ad server. 
03-13 22:23:29.085 17333-17333/com.thecolors I/dalvikvm﹕ Could not find method android.webkit.WebSettings.setMixedContentMode, referenced from method com.google.android.gms.ads.internal.p.a.<init> 
03-13 22:23:29.085 17333-17333/com.thecolors W/dalvikvm﹕ VFY: unable to resolve virtual method 3111: Landroid/webkit/WebSettings;.setMixedContentMode (I)V 
03-13 22:23:29.085 17333-17333/com.thecolors D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x003f 
03-13 22:23:29.085 17333-17333/com.thecolors I/dalvikvm﹕ Could not find method android.webkit.WebSettings.setMediaPlaybackRequiresUserGesture, referenced from method com.google.android.gms.ads.internal.p.a.<init> 
03-13 22:23:29.085 17333-17333/com.thecolors W/dalvikvm﹕ VFY: unable to resolve virtual method 3110: Landroid/webkit/WebSettings;.setMediaPlaybackRequiresUserGesture (Z)V 
03-13 22:23:29.085 17333-17333/com.thecolors D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0054 
03-13 22:23:29.085 17333-17333/com.thecolors I/dalvikvm﹕ Could not find method android.webkit.WebView.evaluateJavascript, referenced from method com.google.android.gms.ads.internal.p.a.evaluateJavascript 
03-13 22:23:29.085 17333-17333/com.thecolors W/dalvikvm﹕ VFY: unable to resolve virtual method 3121: Landroid/webkit/WebView;.evaluateJavascript (Ljava/lang/String;Landroid/webkit/ValueCallback;)V 
03-13 22:23:29.085 17333-17333/com.thecolors D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0016 
03-13 22:23:29.090 17333-17333/com.thecolors I/dalvikvm﹕ Could not find method com.google.android.gms.ads.internal.p.a.isAttachedToWindow, referenced from method com.google.android.gms.ads.internal.p.a.onDraw 
03-13 22:23:29.090 17333-17333/com.thecolors W/dalvikvm﹕ VFY: unable to resolve virtual method 4882: Lcom/google/android/gms/ads/internal/p/a;.isAttachedToWindow()Z 
03-13 22:23:29.090 17333-17333/com.thecolors D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000c 
03-13 22:23:29.090 17333-17333/com.thecolors I/webclipboard﹕ clipservice: [email protected] 
03-13 22:23:29.095 17333-17393/com.thecolors V/webkit﹕ BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {42d5c828} 
03-13 22:23:29.140 17333-17355/com.thecolors D/dalvikvm﹕ GC_FOR_ALLOC freed 8380K, 42% free 13316K/22791K, paused 23ms, total 24ms 
03-13 22:23:29.145 17333-17355/com.thecolors I/dalvikvm-heap﹕ Grow heap (frag case) to 21.844MB for 8310980-byte allocation 
03-13 22:23:29.160 17333-17333/com.thecolors D/dalvikvm﹕ GC_FOR_ALLOC freed <1K, 6% free 21432K/22791K, paused 14ms, total 14ms 
03-13 22:23:29.175 17333-17333/com.thecolors W/Ads﹕ Failed to load ad: 3 
03-13 22:23:29.190 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 8K, 6% free 21435K/22791K, paused 12ms+3ms, total 32ms 
03-13 22:23:29.200 17333-17333/com.thecolors D/webviewglue﹕ nativeDestroy view: 0x5b071b50 
03-13 22:26:57.165 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 10103K, 46% free 13287K/24391K, paused 14ms+3ms, total 48ms 
03-13 22:27:38.000 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 385K, 46% free 13286K/24391K, paused 12ms+3ms, total 40ms 
03-13 22:28:18.885 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 384K, 46% free 13286K/24391K, paused 13ms+3ms, total 37ms 
03-13 22:28:59.760 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 384K, 46% free 13286K/24391K, paused 12ms+4ms, total 38ms 
03-13 22:29:40.710 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 384K, 46% free 13286K/24391K, paused 6ms+3ms, total 30ms 
03-13 22:30:21.675 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 384K, 46% free 13286K/24391K, paused 12ms+3ms, total 37ms 
03-13 22:31:02.635 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 384K, 46% free 13286K/24391K, paused 12ms+4ms, total 37ms 
03-13 22:31:43.590 17333-17334/com.thecolors D/dalvikvm﹕ GC_CONCURRENT freed 384K, 46% free 13286K/24391K, paused 12ms+3ms, total 37ms 
+0

'glView.setEGLConfigChooser (8, 8, 8, 8, 16, 0);' - можно попробовать прокомментировать это? ваш прозрачный GLSurfaceView? – Kiran

+0

> glView.setEGLConfigChooser (8, 8, 8, 8, 16, 0); - Я не знаю, что это, если честно. Это небольшая клейкая лента, которую я нашел в сети. Без этого ничего не получается. – potato

+0

попробуйте изменить название своего пакета и посмотреть, вы получаете эту ошибку, когда вы тестируете api 17+? это связано с тем, что метод на веб-настройках использует методы, добавленные в 17+ и т. д., поэтому проблема заключается в том, что он использует его, если вы тестируете на реальном устройстве, очищаете данные своих сервисов или переименовываете имя своего пакета и видите, помогает ли оно – Elltz

ответ

1

Не уверен, что если вы получили решить эту проблему, но я изо всех сил в течение нескольких ночей с этим же вопросом. Вот как я это решил.

У меня есть приложение, которое также имеет GLSurfaceview. То, что я сделал, чтобы иметь возможность показать рекламные баннеры, чтобы включить AdView в макете, в верхней части (у меня есть LinearLayout внутри RelativeLayout):

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:background="#00000000"> 

    <LinearLayout android:id="@+id/scene1Holder" 
     android:gravity="center_horizontal" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     /> 

    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="false" 
     android:layout_alignParentTop="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="ca-app-pub-xxxxx/xxxxx"> 

    </com.google.android.gms.ads.AdView> 

Затем в OnCreate, прежде, чем добавить glSurfaceView в макет, я инициализировать AdView:

LinearLayout ll = (LinearLayout) this.findViewById(R.id.scene1Holder); 

AdView mAdView = (AdView) findViewById(R.id.adView); 

AdRequest adRequest = new AdRequest.Builder() 
        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
        .build(); 
mAdView.loadAd(adRequest); 
. 
. 
. 
ll.addView(_glSurfaceView); 

в моем приложении, я также был в состоянии показать Intersitial рекламу, просто убедитесь, что использовать другой объект AdRequest.

Надеюсь, это поможет.

+0

Благодарим вас за возможное решение. – potato