无法使用 android MoPub sdk gradle 初始化 Fabric
Can't initialize Fabric with android MoPub sdk gradle
我正在尝试将 MoPub SDK 添加到我的 libgdx 游戏中。我使用了似乎有效的 gradle 集成。但是,我无法为 Fabric 提供新的 MoPub() 对象。我使用 android studio 1.2.1.1。并遵循 https://github.com/mopub/mopub-android-sdk
的要求
Fabric.with(this, new Crashlytics(), new MoPub());
returns 在andoid工作室:
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
由于某种原因,MoPub 对象未被识别为正确的类型。我不明白为什么。
这是我的 gradle 文件的样子:
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;
}
MoPub 不是套件(不扩展套件)。您无需将其添加到 Fabric.with() 调用中。只要您的权限和依赖关系正确,您就可以开始使用它。重申;只是改变这个:
Fabric.with(this, new Crashlytics(), new MoPub());
对此:
Fabric.with(this, new Crashlytics());
请注意,我假设 this
是一个有效的上下文对象。
改变这个
compile('com.mopub:mopub-sdk:4.0.0@aar') {
transitive = true
}
至
compile('com.mopub.sdk.android:mopub:4.0.0@aar') {
transitive = true;
}
前者是独立的 mopub sdk,后者是 fabric kit 的一部分。那应该可以了。
当我将我的项目从 Eclipse 迁移到 Android Studio 时,我遇到了与 Crashlytics 类似的问题(在 Eclipse 中我使用外部 jar 文件,在 Android Studio 中我使用 Gradle ).我只是忘了从 libs 文件夹中删除旧的 Crashlytics jar 文件。我删除后一切正常
我正在尝试将 MoPub SDK 添加到我的 libgdx 游戏中。我使用了似乎有效的 gradle 集成。但是,我无法为 Fabric 提供新的 MoPub() 对象。我使用 android studio 1.2.1.1。并遵循 https://github.com/mopub/mopub-android-sdk
的要求Fabric.with(this, new Crashlytics(), new MoPub());
returns 在andoid工作室:
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
由于某种原因,MoPub 对象未被识别为正确的类型。我不明白为什么。
这是我的 gradle 文件的样子:
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;
}
MoPub 不是套件(不扩展套件)。您无需将其添加到 Fabric.with() 调用中。只要您的权限和依赖关系正确,您就可以开始使用它。重申;只是改变这个:
Fabric.with(this, new Crashlytics(), new MoPub());
对此:
Fabric.with(this, new Crashlytics());
请注意,我假设 this
是一个有效的上下文对象。
改变这个
compile('com.mopub:mopub-sdk:4.0.0@aar') {
transitive = true
}
至
compile('com.mopub.sdk.android:mopub:4.0.0@aar') {
transitive = true;
}
前者是独立的 mopub sdk,后者是 fabric kit 的一部分。那应该可以了。
当我将我的项目从 Eclipse 迁移到 Android Studio 时,我遇到了与 Crashlytics 类似的问题(在 Eclipse 中我使用外部 jar 文件,在 Android Studio 中我使用 Gradle ).我只是忘了从 libs 文件夹中删除旧的 Crashlytics jar 文件。我删除后一切正常