简体   繁体   English

Android Studio插件未找到已安装的Crashlytics

[英]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. 我正在使用版本2.3.2(目前是最新版本),并且遇到以下问题-当我在Application类中初始化crashlytics时,插件无法解决安装问题。 It asks me to make code changes and add the initialization logic to the entry point Activity. 它要求我进行代码更改,并将初始化逻辑添加到入口点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. 另一方面,插件似乎希望它位于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 在我的应用中,android studio插件建议将其转到

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: 我刚刚将其删除,并将以下行放入了我的Application类:

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. 如果需要,可以删除“ .disabled(BuildConfig.DEBUG)”。 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 在您的应用程序build.gradle文件中依赖

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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