inmobi

Error inflating class com.inmobi.ads.InMobiBanner


I followed the InMobi guidelines for Android apps step by step but got the following exception from
DataBindingUtil.setContentView(this, R.layout.mainActivity):

Binary XML file line #670: Binary XML file line #670: Error inflating class com.inmobi.ads.InMobiBanner

<LinearLayout
    xmlns:inmobi="http://schemas.android.com/apk/lib/com.inmobi.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:orientation="vertical">
    <TextView android:text="Ad"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <com.inmobi.ads.InMobiBanner
        android:id="@+id/bannerAdInMobi"
        android:layout_width="320dp"
        android:layout_height="50dp"
        inmobi:placementId="plid-1526902340491"
        inmobi:refreshInterval="60" />
</LinearLayout>

Could anyone offer a tip on how to diagnose it?


Solution

  • Since no one answered after a month, let me post mine. InMobil's support has kindly helped me find the culprit - layout inflation before InMobiSdk.init(). An app needs to run InMobiSdk.init() before inflating the layout.

    My app cannot do this because it uses InMobil ads only under certain conditions (e.g. only the FREE version has ads), so I have removed com.inmobi.ads.InMobiBanner from the layout, and add it in Java code when it is needed.