记一次Flutter升级到3.19,Android遇到的问题

1,101 阅读1分钟

某些插件build报错

  1. java.lang.IllegalAccessError: class org.gradle.internal.compiler.java.ClassNameCollector (in unnamed module @0x1be64679) cannot access class com.sun.tools.javac.code.Symbol$TypeSymbol (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @0x1be64679

    解决办法:在gradlew.propertis中添加如下配置

    org.gradle.jvmargs=--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
    
    • What went wrong: Execution failed for task ':connectivity:compileReleaseJavaWithJavac'. Compilation failed; see the compiler error output for details.

    解决办法:修改connectivity插件的build.gradle内容如下

    group 'io.flutter.plugins.connectivity'
    version '1.0-SNAPSHOT'
    
    buildscript {
        repositories {
            google()
            mavenCentral()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:4.1.0'
        }
    }
    
    rootProject.allprojects {
        repositories {
            google()
            mavenCentral()
        }
    }
    
    apply plugin: 'com.android.library'
    
    android {
        compileSdkVersion 30
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        defaultConfig {
            minSdkVersion 16
        }
    }