简体   繁体   中英

Android studio plugin does not find installed Crashlytics

I am using version 2.3.2 (the latest at this point) and I'm facing the following issue - when I initialize crashlytics inside the Application class, the plugin is not resolving the instalation. It asks me to make code changes and add the initialization logic to the entry point Activity.

The thing that bothers me is which is the right way. The cannonball app has the initialization in its application class. On the other hand it looks like the plugin expects it to be in the Activity. Here is how it looks on the cannonball app:

public class App extends Application {
...
    @Override 
    public void onCreate() { 
    ...
        Fabric.with(this, new Crashlytics(), new Twitter(authConfig), new MoPub());
    }
}

Where as in my app the android studio plugin suggests that it should go to

public class Splash extends ActionBarActivity {
...
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        Fabric.with(this, new Crashlytics(), new Twitter(authConfig), new MoPub());
    ...
    }
}

I think the plugin places it in whatever your main activity is by default. I just removed it and placed the following lines in my Application class:

CrashlyticsCore core = new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build();
Fabric.with(this, new Crashlytics.Builder().core(core).build());

You can remove the ".disabled(BuildConfig.DEBUG)" if you want to. That just disables the plugin if you're in debug mode.

You must include

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

under dependency in your app build.gradle file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM