Reputation: 239
Banner ads from AdMob has been added in the application both in XML and code but while running the application in the external device ,the banner Ad is not shown and the below error is shown in logcat
.
NB: Googled this issue many times but not found any appropriate solution for this problem. Updated the google play service but that not solved the issue.
<?xml version="1.0" encoding="utf-8"?>
<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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_centerInParent="true"
>
<android.support.design.widget.TextInputLayout
android:id="@+id/username_textinput"
android:layout_width="match_parent"
android:padding="5dp"
android:layout_marginTop="15dp"
android:layout_height="wrap_content">
<EditText
android:id="@+id/edittext_agentid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@android:color/black"
android:ems="5"
android:hint="User name"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:imeOptions="actionNext"
android:singleLine="true"
android:textColorHint="#000000"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/edittext_textinput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:padding="5dp">
<EditText
android:id="@+id/edittext_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ems="5"
android:hint="Password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:singleLine="true"
android:textColor="@android:color/black"
android:textColorHint="#000000" />
</android.support.design.widget.TextInputLayout>
<Button
android:layout_marginTop="30dp"
android:id="@+id/button_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LOGIN"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:textColor="#ffffff"
android:layout_gravity="center"
android:background="@color/colorAccent"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/banner_home_footer">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</RelativeLayout>
This is the adrequest code in the activity
adview=(AdView)findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adview.loadAd(adRequest);
While running the application this is the error in logcat
.
/Ads: There was a problem getting an ad response. ErrorCode: 0 W/Ads: Failed to load ad: 0
Upvotes: 0
Views: 145
Reputation: 1802
Test ads as tester
adview=(AdView)findViewById(R.id.adView);
AdRequest adRequest = new
AdRequest.Builder().addTestDevice("your id").build();
adview.loadAd(adRequest);
After run the app... Go in Logcat put in Verbose put in the search field AdRequest, so the id device shows donw.
Upvotes: 1