Build error after migrating from Crashlytics SDK to Fabric

和自甴很熟 提交于 2019-12-19 15:27:48

问题


Recently, we've upgraded our organization's Crashlytics account to Fabric, and I'm trying to replace the old Crashlytics SDK with the new Fabric SDK in our existing apps. I've followed the migration instructions, and it's been largely painless, except that I'm now receiving a build error when I try to compile. The line in question that's causing the error is the bootstrap call:

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

The error that's being returned is:

Error:(55, 11) error: no suitable method found for with(MyActivity,Crashlytics)
method Fabric.with(Fabric) is not applicable
(actual and formal argument lists differ in length)
method Fabric.with(Context,Kit...) is not applicable
(argument type Crashlytics does not conform to vararg element type Kit)

Evidently, new Crashlytics() isn't being recognized as a valid argument for the with(Context,Kit...) method for some reason.

Just to rule out something specifically related to the vararg nature of the method call, I also tried it with more than one kit (e.g. Fabric.with(this, new Crashlytics(), new MoPub())) and the exact same error was still returned.

Finally, I tried moving the call to the onCreate() method of my Application subclass, and that didn't help either.


Relevant sections from build.gradle:

buildscript {
  repositories {
    maven { url 'https://maven.fabric.io/public' }
  }

  dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
  }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

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

dependencies {
  compile fileTree(dir: 'libs', include: '*.jar')
  ...
  compile('com.crashlytics.sdk.android:crashlytics:2.2.1@aar') {
    transitive = true;
  }
}

I've also verified that the Fabric plugin is properly installed and working, and that the old Crashlytics plugin is no longer installed:


回答1:


It turns out that the old Crashlytics JAR was still hiding in my libs folder somehow, and after removing it, this error no longer persists.

I feel a little boneheaded, but I'll leave this up to help any future Googlers who run into the same issue. :)




回答2:


I found exactly what @TreKing mentioned in his comment. The upgrade/migration failed to remove the previous dependency from my app/build.gradle file. Look for an old entry like compile 'com.crashlytics.android:crashlytics:1.1.13' and remove it.



来源:https://stackoverflow.com/questions/28701943/build-error-after-migrating-from-crashlytics-sdk-to-fabric

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!