Android 工作室项目在更新 firebase-perf 插件后未编译(缺少类模块信息)



everyone.我使用的是 gradle 版本 5.6.2。我像这样更新了我的安卓工作室项目依赖项:

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"
}

我像这样应用插件:

apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'com.google.gms.google-services'

但是现在当我编译我的项目时,会出现此错误:

Illegal class file: Class module-info is missing a super type. Class file version 53. (Java 9)

它说问题出在app\build\intermediates\transforms\FirebasePerformancePlugin\bus\debug\9\module-info.class

里面有这个:

module com.google.gson {
requires transitive java.sql;
exports com.google.gson;
exports com.google.gson.annotations;
exports com.google.gson.reflect;
exports com.google.gson.stream;
}

我的猜测是Firebase开始使用Java 9,但我的项目目前正在使用Java 8。我尝试将版本更改为 9,但出现此错误:

Could not target platform: 'Java SE 9' using tool chain: 'JDK 8 (1.8)'.

这是AndroidGradle插件中的一个错误,现已在Android Studio 3.6中修复。 这似乎只是Windows上的问题,因为路径格式使用反斜杠而不是正斜杠/。我确认我可以在 Linux 上的 Android Studio 3.5 上构建我的应用程序,但不能在 Windows 上构建。

通过将其添加到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
}
}

最新更新