Search code examples
androidxmladmobfragmentresolve

Implementing Admob-"Cannnot resolve example..."


I have recently been working and am almost finished with my first app. All that is left is to implement AdMob, but in doing so I keep getting an error in the android:name=... section starting at example. The error is Cannot Resolve Symbol Example and it continues to the other words behind it.

Did I miss something, such as something in the area after com.google.android(where the error is).

<fragment android:name="com.google.android.gms.example.bannerexample.MainActivity$PlaceholderFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/adFragment" />
    <fragment
        android:id="@+id/adFragment"
        android:name="com.google.android.gms.example.bannerexample.MainActivity$AdFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />

Solution

  • The line

    com.google.android.gms.example.bannerexample.MainActivity$AdFragment
    

    is based on the package name used in the example app here. You should be using your own application's package name instead. Quote from the documentation:

    Here we've used "Banner Example" as the Application name and "example.gms.android.google.com" as the company domain. This gives you the package name "com.google.android.gms.example.bannerexample".