Crashlytics - 当应用程序崩溃而未连接到android studio时,无法获取崩溃报告

时间:2017-02-21 18:31:10

标签: android android-studio crashlytics twitter-fabric crashlytics-android

我在我的应用中使用Fabric.io中的crashytics。

以下是我在MainActivity.java onCreate()方法的Fabric.with(this, new Crashlytics()); 初始化它的方法:

build.gradle (Project: abc)

此处有// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenCentral() maven { url 'https://maven.fabric.io/public'} } dependencies { classpath 'com.android.tools.build:gradle:2.2.3' classpath 'com.google.gms:google-services:3.0.0' classpath 'io.fabric.tools:gradle:1.+' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() maven { url "https://dl.bintray.com/hani-momanii/maven"} } } task clean(type: Delete) { delete rootProject.buildDir } 个文件:

build.gradle (Module: app)

此处有apply plugin: 'com.android.application' apply plugin: 'io.fabric' android { compileSdkVersion 25 buildToolsVersion "25.0.0" defaultConfig { applicationId "com.xxx.abc" minSdkVersion 16 targetSdkVersion 25 versionCode 1 versionName "1.0" multiDexEnabled true vectorDrawables.useSupportLibrary = true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } repositories { mavenCentral() maven { url "https://jitpack.io" } maven { url 'https://maven.fabric.io/public' } } dexOptions { javaMaxHeapSize "4g" } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') { transitive = true; } } apply plugin: 'com.google.gms.google-services' 个文件:

<meta-data
   android:name="io.fabric.ApiKey"
   android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxx"
 />

AndroidManifest.xml<application>代码之间的var path = require('path'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = { entry: path.resolve(__dirname, './app/app.module.js'), output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' }, devtool: 'source-map', module: { loaders: [{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/, query: { presets: ['es2015'] } }, { test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) }, { test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/, loader: 'file-loader?name=[name].[ext]&publicPath=../fonts/&outputPath=/assets/fonts/' }, { test: /\.(jpe?g|png|gif)$/i, loader: 'file-loader?name=/assets/images/[name].[ext]' }, { test: /\.(html)$/, loader: 'file-loader?name=[path][name].[ext]' }, { test: /\.(json)$/, loader: 'file-loader?name=[path][name].[ext]' }, { test: /\.scss$/, loader: ExtractTextPlugin.extract({ use: [{ loader: 'css-loader' }, { loader: 'sass-loader' // compiles Sass to CSS }], fallback: 'style-loader' }) } ] }, plugins: [ new ExtractTextPlugin('assets/css/styles.css') ] }; 中定义。

问题我无法在应用崩溃但未连接到Android Studio时收到崩溃报告,但是当应用程序在连接时崩溃时我会收到报告。< / p>

为什么会发生这种情况?我怎样才能每次应用崩溃时都会收到崩溃报告是否与Android Studio连接?

1 个答案:

答案 0 :(得分:2)

Activity移除并放入应用

public class MyApplication extends Application {

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

}

不要忘记在manifest.xml应用标记中添加名称

<application
    ...
    android:name=".MyApplication"
    ...
</application>