Search code examples
androidandroid-studiolibgdxmopub

Can't initialize Fabric with android MoPub sdk gradle


I am trying to add MoPub SDK to my libgdx game. I used the gradle integration which seem to work. However I can not feed Fabric with a new MoPub() object. I use android studio 1.2.1.1. And followed the requirement at https://github.com/mopub/mopub-android-sdk

Fabric.with(this, new Crashlytics(), new MoPub());

returns in andoid studio:

Error:(89, 15) error: method with in class Fabric cannot be applied to given types;
required: Context,Kit[]
found: AndroidLauncher,Crashlytics,MoPub
reason: varargs mismatch; MoPub cannot be converted to Kit

for some reason the MoPub object is not recognized as the right type. I don't see why.

this is what my gradle file looks like:

repositories {
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}

configurations { natives }

dependencies {
    compile project(":core")

    compile files('libs/mopub-volley-1.1.0.jar')
    compile files('libs/android-support-v7-recyclerview.jar')
    compile files('libs/annotations-4.1.1.4.jar')
    compile files('libs/android-support-v4.jar')

    compile('com.mopub:mopub-sdk:4.0.0@aar') {
        transitive = true
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.2.2@aar') {
        transitive = true;
    }

Solution

  • Change this

    compile('com.mopub:mopub-sdk:4.0.0@aar') {
            transitive = true
        }
    

    to

    compile('com.mopub.sdk.android:mopub:4.0.0@aar') {
                transitive = true;
            }
    

    former is standalone mopub sdk and later is part of fabric kit. It should work then.