Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
277 views
in Technique[技术] by (71.8m points)

android - How to initialize Crashlytics in Fabric.io?

Looking for some help. I just upgraded my android app to fabric and now the app gives an error on this line:

Crashlytics.start(getApplicationContext());

Gradle: error: cannot find symbol method start(Context)

I tried commenting out that line, but then the crashes are not getting logged. How do I initialize Crashlytics in the new fabric framework? Am I missing something?

Thanks in advance for your help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since Crashlytics is now part of Fabric the initialization process has changed, but is still simple. Instead of using Crashlytics.start() you should now use, but in the Application creation:

public class App extends Application {

    ...

    @Override
    public void onCreate() {
        super.onCreate();
        Fabric.with(this, new Crashlytics());
    }

    ...

}

For a more richer example, see how Cannonball canonical sample app is doing:

public class App extends Application {

    ...

    private TwitterAuthConfig authConfig;

    ...

    @Override
    public void onCreate() {
        super.onCreate();
        authConfig = new TwitterAuthConfig(BuildConfig.CONSUMER_KEY, BuildConfig.CONSUMER_SECRET);
        Fabric.with(this, new Crashlytics(), new Twitter(authConfig), new MoPub());
    }

    ...

}

This code is available at: https://github.com/twitterdev/cannonball-android/blob/master/app/src/main/java/io/fabric/samples/cannonball/App.java#L96-L98


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...