Android studio project not compiling after updatin

2020-06-25 05:16发布

问题:

everyone. I'm using gradle version 5.6.2. I updated my android studio project dependencies like this:

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

I apply the plugins like this:

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

But now when I compile my project this error shows up:

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

It says the problem is in app\build\intermediates\transforms\FirebasePerformancePlugin\bus\debug\9\module-info.class

Inside there's this:

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

My guess is that firebase started using Java 9 but my project is currently working with Java 8. I tried changing the version to 9 but I get this error:

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

回答1:

This is a bug in the Android Gradle plugin, fixed now in Android Studio 3.6. It looks to only be an issue on Windows, as the path format uses the backslash \ instead of forward slash /. I confirmed I am able to build my app on Android Studio 3.5 on Linux, but not Windows.