4

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;
    }
AxlDotm
  • 43
  • 3

3 Answers3

4

MoPub isn't a Kit (doesn't extend Kit). You don't need to add it to your Fabric.with() call. As long as your permissions and dependencies are correct then you can just start using it. To reiterate; just change this:

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

to this:

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

Note that i'm assuming this is a valid Context object.

davehenry
  • 1,026
  • 9
  • 24
  • MoPub seems to work since my log cat displays attempt to load ads but fails since I don't have any mopub id yet. However I'd like to use the Fabric plugin and dashboard. The Fabric plugin stay stuck on "please build and run your application" since I actually never feed fabric with mopub. – AxlDotm Oct 29 '15 at 06:34
  • @davehenry, when did this change? – Etienne Lawlor Dec 10 '15 at 00:53
  • hmm i'm not sure. Its been this way sine we upgraded to Fabric several months ago – davehenry Dec 11 '15 at 07:46
2

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.

lightsaber
  • 1,481
  • 18
  • 37
0

I had a similar problem with Crashlytics when I migrated my project from Eclipse to Android Studio (in Eclipse I used an external jar file, in Android Studio I use Gradle). I simply forgot to delete the old Crashlytics jar file from the libs folder. After I deleted it, everything worked fine.

strongmayer
  • 488
  • 1
  • 5
  • 14