简体   繁体   中英

App Crashing After Adding Applovin Max Banner Ad

I have tried implementing the banner ad code following the correct documentation as seen here . Now when I run the app both on my Virtual Device and Mobile phone crashes after showing the splash screen.

My error is pointing to:

        setContentView(R.layout.activity_main);

I have also implemented MaxAdViewAdListener in my MainActivity.java

On my activity_main design below is how I have added the banner ad code as below:

        <com.applovin.mediation.ads.MaxAdView
            android:layout_width="match_parent"
            android:layout_height="@dimen/banner_height"
            android:background="@color/banner_background_color"
        android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            maxads:adUnitId="e96696c22#####" />

The Ad although displays in the Design section on Android studio. Below are the exceptions displayed in the Run section:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.packagename.eaxample/com.packagename.eaxample.MainActivity}: android.view.InflateException: Binary XML file line #371 in com.packagename.eaxample:layout/activity_main: Binary XML file line #371 in com.packagename.eaxample:layout/activity_main: Error inflating class com.applovin.mediation.ads.MaxAdView

 Caused by: android.view.InflateException: Binary XML file line #371 in com.packagename.example:layout/activity_main: Binary XML file line #371 in com.packagename.example/activity_main: Error inflating class com.applovin.mediation.ads.MaxAdView
 Caused by: android.view.InflateException: Binary XML file line #371 in com.packagename.example:layout/activity_main: Error inflating class com.applovin.mediation.ads.MaxAdView

With this Error inflating class com.applovin.mediation.ads.MaxAdView , you have to check the following:

  1. Check if your com.applovin.mediation.ads.MaxAdView in XML file can be referenced. If not, you may have to confirm if you have imported the correct libraries.
  2. It uses an additional namespace: maxads:adUnitId . Check if the corresponding link for this namespace is correctly set: xmlns:maxads="http://schemas.applovin.com/android/1.0"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM