非法类文件:类模块信息缺少超类型。类文件版本 53

Eld*_*opj 19 android gradle android-studio firebase-performance

当我将 firebase perf 依赖项添加到我的项目中时,我收到此错误Illegal class file: Class module-info is missing a super type. Class file version 53. 我的 Gradle 和 google 服务项目级依赖项是

    classpath 'com.android.tools.build:gradle:3.5.1'
    classpath 'com.google.gms:google-services:4.3.2'
Run Code Online (Sandbox Code Playgroud)

我遵循了他们的文档https://firebase.google.com/docs/perf-mon/get-started-android 中提到的确切步骤。

我尝试过清理和重建并清除 Android Studio 缓存。

并且还尝试了来自 StackOverflow 的类似问题解决方案

项目级构建gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com' }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.3.2'
        classpath 'com.google.firebase:perf-plugin:1.3.1'  // Performance Monitoring plugin
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}
Run Code Online (Sandbox Code Playgroud)

应用级构建gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://jitpack.io" }
        jcenter()

    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.31.0'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
// Apply the Performance Monitoring plugin to enable instrumentation
apply plugin: 'com.google.firebase.firebase-perf'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://jitpack.io" }
    maven {
        url 'https://maven.google.com'
    }

}
dependencies {
// Not added all dependencies , Just the firebase one SINCE ITS PRETTY LONG
implementation 'com.google.firebase:firebase-perf:19.0.0'
}
Run Code Online (Sandbox Code Playgroud)

Sid*_*yak 29

将此添加到您的应用程序级build.gradle文件可以暂时解决问题

debug {
          FirebasePerformance {
            // Set this flag to 'false' to disable @AddTrace annotation processing and
            // automatic HTTP/S network request monitoring
            // for a specific build variant at compile time.
            instrumentationEnabled false
          }
        }
Run Code Online (Sandbox Code Playgroud)

根据其他答案和评论进行编辑

将 gradle 插件更改3.6.0为解决它,因为它已在该版本中修复

  • 这解决了我的问题,谢谢。我认为,有人应该将此报告给错误跟踪器。 (2认同)

ken*_*yee 6

仅供参考,这是一个 AGP 错误......它已在 AGP 3.6 中修复