【问题标题】:I'm trying to apply crashlytics and an error has occurred in gradle我正在尝试应用 crashlytics 并且 gradle 中发生错误
【发布时间】:2019-10-02 09:58:21
【问题描述】:

存在一个问题,即现有应用程序经常被强制终止。 在搜索相关技术以报告来自这些远程设备的错误消息时,我遇到了 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

我不明白问题出在哪里,因为错误消息根本没有意义。我不知道这是否只是我所指的库之间的编码损坏或版本问题。

【问题讨论】:

  • 您是否尝试过清理和重建项目?
  • 检查天气,您的课程或 xms 中有一些错误。有关更多信息,我建议您查看 this 关于堆栈溢出的帖子
  • @solaza 我重建了很多次,但没有成功。在家里把所有的代码都炸了,边喝啤酒边编码,解决了。编码的朋友是啤酒..
  • @AlirezaBideli 谢谢你的建议!

标签: android firebase android-gradle-plugin crashlytics


【解决方案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>


【讨论】:

  • 我不确定是什么问题,但我清理了所有代码并在家里再次尝试。谢谢你的建议!
猜你喜欢
  • 2020-11-18
  • 2020-08-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-27
  • 1970-01-01
相关资源
最近更新 更多