我正在尝试应用crashlytics,并且在gradle中发生了错误

问题描述 投票:0回答:1

存在一个问题,即现有应用经常被迫终止。在搜索相关技术以报告来自这些远程设备的错误消息时,我遇到了firebase crashlytics,并希望将其应用。

但是,当我根据指南添加代码时,问题发生在gradle脚本中。

尝试链接:https://firebase.google.com/docs/crashlytics/get-started?platform=android

新添加的代码在__之间。

// project gradle

buildscript {
    repositories {
        google()
        jcenter()
        __maven {
            url 'https://maven.fabric.io/public'
        }__

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        __classpath 'com.google.gms:google-services:4.3.0'
        classpath 'io.fabric.tools:gradle:1.31.0'__

    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


// app gradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    signingConfigs {
        debug {
            // ...
        }
    }
    compileSdkVersion 28
    defaultConfig {
        applicationId // ...
        minSdkVersion 19
        targetSdkVersion 24
        versionCode // ...
        versionName // ...
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            signingConfig signingConfigs.debug
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    __implementation 'com.google.firebase:firebase-core:17.0.1'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'__

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    api 'com.journeyapps:zxing-android-embedded:3.6.0'
    api 'com.google.zxing:core:3.3.0'
    api 'com.github.felHR85:UsbSerial:3.3'
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

___apply plugin: 'com.google.gms.google-services'___

同步失败消息

 -> ASCII

运行构建消息

 -> org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Build file '${project}\app\build.gradle' line: 1
 -> A problem occurred evaluating project ':app'
  ...\
 -> Caused by: org.gradle.internal.exceptions.LocationAwareException: Build file '${project}\app\build.gradle' line: 1

我不明白问题是什么,因为错误消息根本没有意义。我不知道这是我要引用的库之间的编码错误还是版本问题。

android firebase android-gradle crashlytics
1个回答
1
投票

将这些行添加到清单中:

<meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />

如果仍然无法正常工作,请将您的应用迁移到androidX然后将应用程序类转换为MultiDexApplication类

应用程序级别build.gradle

buildTypes {
    release {
        multiDexEnabled true;

    }
    debug {
        multiDexEnabled true;

    }
}

dependencies {  
    implementation 'com.android.support:multidex:1.0.3'
}

创建MultiDexApplication类:


public class MyApplication extends MultiDexApplication {

    @Override
    public void onCreate() {
        super.onCreate();

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

AndroidManifest.xml中设置新类别

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

</application>


© www.soinside.com 2019 - 2024. All rights reserved.