I want to upgrade one source code from the old GoogleAds SDK to the new Google Play Service Library , but there is a problem. Every time I got this error:
Failed to get ad response.
ErrorCode: 0
Failed to load ad: 0
This is the code from playactivty:
public String BANNER_AD_UNIT_ID; AdRequest adRequest; private void LoadAds() { LinearLayout layout = (LinearLayout) findViewById(R.id.adView); this.BANNER_AD_UNIT_ID = getResources().getString(R.string.admob_id);
And from layout.xml
</RelativeLayout> <com.google.android.gms.ads.AdView android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="@string/admob_id"> </com.google.android.gms.ads.AdView> <LinearLayout android:orientation="horizontal" android:id="@+id/adView" android:layout_width="fill_parent" android:layout_height="wrap_content"> </LinearLayout>
What did I do there? I can not find the problem and trust me, I read all the SOF messages about this error :)
Many thanks!
Edit:
Source:
PlayActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_play); LoadConfigParams(); LoadSharedPreferences(); LoadResources(); LoadListeners(); LoadStage(mCurStage); LoadAds(); } private void LoadAds() { LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayoutAdmob);
activity_play.xml (only the latest LinearLayout code, above RelativeLayout).
<LinearLayout android:id="@+id/linearLayoutAdmob" android:layout_width="fill_parent" android:layout_height="wrap_content"></LinearLayout>
source share