Admob not show in lollipop 5.1 device

我们两清 提交于 2019-12-12 10:25:21

问题


hello friends i wnat ot integrate admob in my application so i set following code for that

Main.java

public class Main extends Activity{

 AdView adView;
 RelativeLayout mRelativeLayoutRoot;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.advs);
    mRelativeLayoutRoot=(RelativeLayout)findViewById(R.id.root);


    adView = new AdView(this);
    adView.setAdSize(AdSize.BANNER);
    adView.setAdUnitId(getResources().getString(R.string.admob_unit_id));
    adView.setId(11);
    LayoutParams lp;
    lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); // You might want to tweak these to WRAP_CONTENT
    lp.addRule(mRelativeLayoutRoot.ALIGN_PARENT_BOTTOM);
    mRelativeLayoutRoot.addView(adView, lp);
    AdRequest adRequest = new AdRequest.Builder()
    .build();

    adView.loadAd(adRequest);

}

}

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
            <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <activity
        android:name=".Main"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
     <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

</application>

</manifest>

When i run above code advertisement show only Jellybean , kitkat mobile device in Lolliop device 5.1 it is not showing any idea how can i solve this problem ?

EDIT

When i run this cod ein Micomax android one phone (Lollipop 5.1) it is not show advertise on that


回答1:


Suggest you start by creating your AdView in the XML layout for your Activity rather than in code. It will help eliminate a few potential errors.

Next, make sure that you have added the deviceIds for the 2 devices as test device ids.

Finally, look at your logcat for the 2 devices and see what the Admob log says in the case when the ad does not load.



来源:https://stackoverflow.com/questions/30213313/admob-not-show-in-lollipop-5-1-device

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!