Required XML attribute “adSize” was missing on eclipse juno (api 14 - 22)

183 views
Skip to first unread message

Arnold Sia

unread,
Jun 21, 2015, 11:24:03 PM6/21/15
to google-adm...@googlegroups.com
Hello,

            I have tried a lot of solutions over the internet thru google search, it seems that it does not display my banner adds, since I am on a testing phase.
Here is my android manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="myapp.package"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="22" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <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"/>
        <meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />
        <activity
            android:name=".MyActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

Here is my xml file at layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/container"  
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="@dimen/activity_vertical_margin"
    tools:context=".MyActivity"
    tools:ignore="MergeRootFrame">
   
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginStart="@dimen/activity_horizontal_margin"
        android:text="@string/hello_world" />

    <com.google.android.gms.ads.AdView
        android:id="@+id/ad_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:testDevices="B3EEABB8EE11C2BE770B684D95219"
        ads:loadAdOnCreate="true"
        ads:refreshInterval="60" />
</RelativeLayout>

Here is my class file:
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;

import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;

public class MyActivity extends ActionBarActivity
{
    private AdView mAdView;
    private static final String AD_UNIT_ID = "53737733288";
   
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);

        String deviceId = "B3EEABB8EE11C2BE770B684D95219";
        // Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in
        // values/strings.xml.
        mAdView = (AdView) findViewById(R.id.ad_view);

        // Create an ad request. Check logcat output for the hashed device ID to
        // get test ads on a physical device. e.g.
        AdRequest adRequest = new AdRequest.Builder()
                .addTestDevice("B3EEABB8EE11C2BE770B684D95219")
                .build();
        mAdView.setAdSize(AdSize.SMART_BANNER);
        mAdView.setAdUnitId(AD_UNIT_ID);
        // Start loading the ad in the background.
        mAdView.loadAd(adRequest);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings)
        {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /** 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();
    }
}

Please help, I am having trouble looking for solution. Thank you.
TestAdMobBannerAdds1.jpg

Vu Chau (MobileAds SDK Team)

unread,
Jun 22, 2015, 2:50:57 PM6/22/15
to google-adm...@googlegroups.com, apsin...@gmail.com
Hi Arnold,

Is there a reason for your setting the adSize in code? We had a similar case reported recently, whereby defining the adSize attribute in the XML (rather than in the Java code) should rectify the issue.  Could you give that a try and let us know if that fixes the error?

If you haven't, we currently recommend walking through our Android quick start guide for setting up a test project in Android Studio.  If you need help migrating your project from Eclipse to Android Studio, please visit this page for more information.  

Cheers,

Vu Chau
MobileAds SDK Team

Arnold Sia

unread,
Jun 22, 2015, 7:48:19 PM6/22/15
to google-adm...@googlegroups.com, apsin...@gmail.com
Hello Vu,

        I have no particular reason in putting adsize inside the java code instead in xml. I was able to display the ad once but when I try again, ad did not display again. Is there a way to display the adds either horizontally or vertically and adjust its size depending on screen size so I don't need to set the ads width and height. How long will the loading of interstitial adds to load and show? I tried this one too but I was able to display once then when I try again did not display. It takes time to set up from eclipse to android studio, and my internet bandwidth is slow and limited. May be in the future. Is the android studio more stable and less error than eclipse?

Thank you,
Arnold

Vu Chau (MobileAds SDK Team)

unread,
Jun 23, 2015, 3:46:41 PM6/23/15
to google-adm...@googlegroups.com, apsin...@gmail.com
Hi Arnold,

As per our documentation, we only support horizontal banner ads.  For adaptable banner ads that will adjust their sizes (before being fetched) to the device's orientation and dimensions, we recommend giving smart banners a try. 

Regarding interstitial ads, it will take a some time (but not anything extraordinary) to load it.  That is why we recommend loading an interstitial ad prior to displaying it at a later point in time.  If you want to display an interstitial again, you would have to destroy the AdView.  For more info, please visit this tutorial.

We do not give product recommendations, but currently Android Studio is the official IDE for Android development.

Vu Chau
MobileAds SDK Team

Arnold Sia

unread,
Jun 25, 2015, 5:30:26 AM6/25/15
to google-adm...@googlegroups.com, apsin...@gmail.com
Hello Vu,

        I was able to combine both content or view into one. But my ads did not display but only the game work, yes, I set admob ads in code not in xml. Anyway, here is the partial logcat saying ad failed to load:
Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
unable to resolve virtual method 325: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
replacing opcode 0x6e at 0x00c2
Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzh
unable to resolve virtual method 614: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
replacing opcode 0x6e at 0x000b
Google Play services is missing.
There was a problem getting an ad response. ErrorCode: 0
Failed to load ad: 0

How can add admob ads into existing layout?

Thank you,

Arnold

Vu Chau (MobileAds SDK Team)

unread,
Jun 25, 2015, 2:49:25 PM6/25/15
to google-adm...@googlegroups.com, apsin...@gmail.com
Hi Arnold,

As per the crash log, Google Play services appears to be missing.  Could you confirm if you have it installed, and if so, which version of Google Play services is your app compiled against?

We recommend you to walk through our Android quick start to double check that everything is set up properly.  If you still have problems, let us know!

Vu Chau
MobileAds SDK Team


Arnold Sia

unread,
Jun 25, 2015, 8:04:23 PM6/25/15
to google-adm...@googlegroups.com, apsin...@gmail.com
Hello Vu,

        I have attached two image which shows you google play services has been downloaded and installed unless there is another sdk package. I have follow the instructions in this link to serve google play services as library, https://developers.google.com/android/guides/setup.

Thank you,

Arnold
SDKManagerGooglePlayServicesPackageInstalled1.jpg
GooglePlayServicesProjectInEclipse1.jpg

Vu Chau (MobileAds SDK Team)

unread,
Jun 26, 2015, 2:50:17 PM6/26/15
to google-adm...@googlegroups.com, apsin...@gmail.com
Hi Arnold,

Thanks for the details!  

We have a help article on how to integrate AdMob into an existing project, which you can reference here.  

Regarding the issue with Google Play services missing, I suspect it as having to do with the import and integration process.  In the project properties, please check that Google Play services is properly linked to your project and that it is exported.  For more details, please consult this quick start for Eclipse.  Alternatively, please consider using Android Studio with Gradle to better manage your dependencies.

Thanks,

Vu Chau
MobileAds SDK Team

Arnold Sia

unread,
Jul 2, 2015, 2:52:21 AM7/2/15
to google-adm...@googlegroups.com, apsin...@gmail.com
I have able to display the adview but no ads, as usual failed to load ad (banner). I have attached an image displaying a white blank space above the game but not ad.
SubmarineAdventuresBlankWhiteTop1.jpg
SubventurePromoGraphic1.png

Vu Chau (MobileAds SDK Team)

unread,
Jul 6, 2015, 4:28:08 PM7/6/15
to google-adm...@googlegroups.com, apsin...@gmail.com
Hi Arnold,

Thanks for the screenshot! As seen, the blank space might not be enough space allocated for the AdView to display a banner.  Please use your ad unit ID in our sample example to check if any banner is successfully displayed.  If it does, please double check your MobileAds implementation to make sure that 1) enough space is allocated for a banner, and 2) the right banner size is requested for the given AdView.

Vu Chau
MobileAds SDK Team

Reply all
Reply to author
Forward
0 new messages