更新firebase-perf插件后,Android Studio项目无法编译(缺少Class module-info)。

3

大家好,我正在使用Gradle 5.6.2版本。我通过以下方式更新了我的Android Studio项目依赖:

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)'.
2个回答

5

这是Android Gradle插件的一个错误,现在已经在Android Studio 3.6中得到修复。此问题似乎只出现在Windows上,因为路径格式使用反斜杠符号\而不是正斜杠符号/。我确认我能够在Linux上的Android Studio 3.5构建我的应用程序,但在Windows上无法构建。


1

通过将以下内容添加到 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
          }
        }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接