AndroidStudio 编译报错Unable to make field private final

用 AndroidStudio 打开某个工程后,编译报错如下

Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @5a056318

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

这个工程在其他人那里是 OK 的,那大概率是 gradle 配置的问题。

修改 project 的 build.gradle ,gradle 版本改成自己的。

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        //classpath "com.android.tools.build:gradle:4.1.2"
        classpath "com.android.tools.build:gradle:7.1.1"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

你可能感兴趣的:(Android,AndroidStudio,android)