I can not find the right place to insert ADMOB ad

32 views Asked by At

When I place ads, the app closes!

I made these processes app/build.gradle

implementation 'com.google.firebase:firebase-ads:17.0.0'
}
apply plugin: 'com.google.gms.google-services'

the project has several activities, I put it in BaseActivity

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


public abstract class BaseActivity extends AppCompatActivity {
    private AdView mAdView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_entry);

        mAdView = findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);
    }

It also has several xml in the layout, I put it in activity_entry.xml

 <com.google.android.gms.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
        </com.google.android.gms.ads.AdView>


</FrameLayout>

I can not identify what is wrong, the print below shows all activity and xml, the project is also available to anyone who can help

Print Download the project to help you better: https://mega.nz/#!O481VIiA!OV9_qShNl5H_ALkEx9CZRW-kfhKoCSYw_7fJ0x0R4Ic

0

There are 0 answers