I can’t fix the bug with adUnitId

Asked

Viewed 38 times

0

The command of the line ads:adUnitId="@string/banner_ad_unit_id" of xml is not recognized in any way by Android Studio.

inserir a descrição da imagem aqui

I just added import import com.google.android.gms.ads.MobileAds; in the referent Activity and I realized that the ads (so I researched) are included in the project:

inserir a descrição da imagem aqui

But it always comes up.

inserir a descrição da imagem aqui

Xml code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:paddingBottom="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:paddingTop="10dp"
    android:background="@drawable/back_01_04"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="genesysgeneration.ruleoftree.MainActivity01">

    <TextView
        android:id="@+id/tv01"
        android:layout_width="100dp"
        android:layout_height="88dp"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/et03"
        android:background="@drawable/text_box_03_mirror" />

    <ImageView
        android:id="@+id/btnCompras"
        android:layout_width="75dp"
        android:layout_height="60dp"
        app:srcCompat="@drawable/carrinho"
        android:layout_above="@+id/space7"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <ImageView
        android:id="@+id/btnMoeda"
        android:layout_width="41dp"
        android:layout_height="60dp"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/btnCompras"
        app:srcCompat="@drawable/cifrao_02" />

    <EditText
        android:id="@+id/et01"
        android:layout_width="100dp"
        android:layout_height="88dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/btnInfo"
        android:layout_marginTop="80dp"
        android:background="@drawable/text_box_03"
        android:ems="10"
        android:inputType="number|numberDecimal" />

    <EditText
        android:id="@+id/et02"
        android:layout_width="100dp"
        android:layout_height="88dp"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/et01"
        android:background="@drawable/text_box_03_mirror"
        android:ems="10"
        android:inputType="number|numberDecimal" />

    <EditText
        android:id="@+id/et03"
        android:layout_width="100dp"
        android:layout_height="88dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/et01"
        android:layout_marginTop="54dp"
        android:background="@drawable/text_box_03"
        android:ems="10"
        android:inputType="number|numberDecimal" />

    <ImageView
        android:id="@+id/btnInfo"
        android:layout_width="29dp"
        android:layout_height="40dp"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        app:srcCompat="@drawable/info_02" />

    <ImageView
        android:id="@+id/btnChange01"
        android:layout_width="72dp"
        android:layout_height="50dp"
        android:layout_alignTop="@+id/et02"
        android:layout_centerHorizontal="true"
        app:srcCompat="@drawable/img_change" />

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id"/>

    <Space
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_above="@+id/adView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:id="@+id/space7" />
</RelativeLayout>

1 answer

0


In the archive res/values/strings.xml you have to create an item with this id:

<resources>
    <string name="banner_ad_unit_id">código do unit ID do seu ad</item>
</resources>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.