Q:

button cannot be cast to com.google.android.gms.ads.adView

I'm getting this error message when starting app: button cannot be cast to com.google.android.gms.ads.adView
and my main xml is:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/fondo_tablero_claro">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/ad"
        android:layout_marginBottom="10dp"
        android:layout_alignParentTop="true">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="center_horizontal"
            android:gravity="center_horizontal">
            <Button android:textSize="@dimen/lletra_normal"
                android:id="@+id/button_jugar"
                android:layout_width="@dimen/botons_width"
                android:layout_height="@dimen/botons_hight"
                android:layout_marginTop="@dimen/menu_principal_margin_top"
                android:text="@string/Jugar" android:textStyle="bold"
                android:onClick="callJoc"
                android:background="@anim/custom_button">
            </Button>
            <Button android:textSize="@dimen/lletra_normal"
                android:id="@+id/button_millor_puntuacio"
                android:layout_width="@dimen/botons_width"
                android:layout_height="@dimen/botons_hight"
                android:layout_marginTop="@dimen/menu_principal_margin_top"
                android:text="@string/Records" android:gravity="center"
                android:textStyle="bold" android:onClick="callRecords"
                android:background="@anim/custom_button">
            </Button>
            <Button android:textSize="@dimen/lletra_normal"
                android:id="@+id/button_instruccions"
                android:layout_width="@dimen/botons_width"
                android:layout_height="@dimen/botons_hight"
                android:layout_marginTop="@dimen/menu_principal_margin_top"
                android:text="@string/Instruccions" android:gravity="center"
                android:textStyle="bold" android:onClick="callInstruccions"
                android:background="@anim/custom_button">
            </Button>
            <Button android:textSize="@dimen/lletra_normal"
                android:id="@+id/button_shop"
                android:layout_width="@dimen/botons_width"
                android:layout_height="@dimen/botons_hight"
                android:layout_marginTop="@dimen/menu_principal_margin_top"
                android:text="@string/shop" android:gravity="center"
                android:textStyle="bold" android:onClick="callTienda"
                android:background="@anim/custom_button">
            </Button>
        </LinearLayout>
    </ScrollView>
    <com.google.android.gms.ads.AdView 
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/ad"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adUnitId="ca-app-pub-9865093044546350/6563553024"
        ads:adSize="SMART_BANNER"/>
</RelativeLayout>

and my .java is:
    public class matriX extends Activity
{
    Dialog porNiveles, principal;
    Intent intent;
    Bundle extra;
    NumberPicker level;
    int NivelMax;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        SharedPreferences prefs = this.getSharedPreferences("Scores"
                , Context.MODE_PRIVATE);
        if (!prefs.contains("score1")){
            prefs.edit().putInt("score1",00000).apply();
            prefs.edit().putInt("score2",00000).apply();
            prefs.edit().putInt("score3",00000).apply();
            prefs.edit().putInt("score4",00000).apply();
            prefs.edit().putInt("score5",00000).apply();
        }
        NivelMax = prefs.getInt("nivel", 1);
        AdView adView = (AdView)this.findViewById(R.id.ad);
        AdRequest adRequest = new AdRequest.Builder().addTestDevice
                ("****).build();
        adView.loadAd(adRequest);
    }

    public void callJoc(View view){
        starts of the dialog

        //INIT PRINCIPAL
        LinearLayout Candado = (LinearLayout) principal.findViewById(R.id.modoCandado);
        LinearLayout Libre = (LinearLayout) principal.findViewById(R.id.modoLibre);
        Button Niveles = (Button) principal.findViewById(R.id.botonNivel);
        Button cancelar = (Button) principal.findViewById(R.id.bcancel);

        cancelar.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                principal.cancel();             
            }
        });

        Niveles.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View v) {
                principal.cancel(); 
                porNiveles.show();
            }
        });

        if (NivelMax >= 30) {
            Candado.setVisibility(View.GONE);
            Libre.setVisibility(View.VISIBLE);
            Button but = (Button) principal.findViewById(R.id.botonInfinitoLibre);
            but.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    extra.putInt("mode", 0);//modo infinito
                    intent.putExtras(extra);
                    startActivity(intent);
                }
            });
        }
        else {
            Button buto = (Button) principal.findViewById(R.id.botonInfinitoBlock);
            buto.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Context context = matriX.this;
                    CharSequence text = getString(R.string.cantAcces);
                    int duration = Toast.LENGTH_LONG;
                    Toast toast = Toast.makeText(context, text, duration);
                    toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL, 0, 0);
                    toast.show();
                }
            });
        }

        //INIT PORNIVELES
        level = (NumberPicker) porNiveles.findViewById(R.id.levelpick);
        Button back = (Button) porNiveles.findViewById(R.id.back);
        Button empezar = (Button) porNiveles.findViewById(R.id.empezar);
        String[] nums_diners = new String[6];
        nums_diners[0] = "1";
        for(int i = 1; i<nums_diners.length; i++){
            nums_diners[i] = Integer.toString((i)*5);
        }
        level.setMinValue(0);
        int valor = NivelMax/5;
        if(NivelMax < 26) level.setMaxValue(valor);
        else level.setMaxValue(5);
        level.setWrapSelectorWheel(false);
        level.setDisplayedValues(nums_diners);
        empezar.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

my click listener
                }
            });
            back.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    porNiveles.cancel();
                    principal.show();
                }
            });
        porNiveles.setCanceledOnTouchOutside(true);
        principal.setCanceledOnTouchOutside(true);
        principal.show();
    }

more function calls..

A:

Seems I found my mistake, I had to remove those lines from RelativeLayout:
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"

I think it caused advert and buttons to be on the same place even that on eclipse I didn't see it that way

