颤振构建 gradle 失败 ':firebase_core:compileDebugJavaWithJavac'

时间:2021-04-18 13:14:51

标签: flutter

我最近重置了我的电脑,所以我的项目路径发生了变化,不知道是否与此错误有关。

我尝试更改 minSdkversion,编译 SDK 版本,升级和降级所有 firebase 插件,但没有成功。

这是我的完整错误日志

Launching lib\main.dart on Android SDK built for x86 in debug mode...
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core- 
1.0.3\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:92: 
error: cannot find symbol
    () -> {
    ^
symbol:   method metafactory(Lookup,String,MethodType,MethodType,MethodHandle,MethodType)
location: interface LambdaMetafactory
Fatal Error: Unable to find method metafactory

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':firebase_core:compileDebugJavaWithJavac'.   
> Compilation failed; see the compiler error output for details.        

* 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.

* Get more help at https://help.gradle.org

 BUILD FAILED in 32s

这是我的 build.gradle 文件

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
    localProperties.load(reader)
  }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the 
local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
 }

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
 }

 apply plugin: 'com.android.application'
 apply plugin: 'kotlin-android'
 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 30

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    // TODO: Specify your own unique Application ID 
(https://developer.android.com/studio/build/application-id.html).
    applicationId "com.orangesprout.wlyk"
    buildToolsVersion = "28.0.3"
    minSdkVersion 23
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    multiDexEnabled true
}

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.debug
      }
   }
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:26.5.0')
implementation 'com.google.firebase:firebase-analytics'
}

应用插件:'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

从错误日志来看,这个位置的第 92 行似乎存在语法错误

C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.0.3\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java

所以你可以去那个位置编辑文件并修复错误,或者我建议你 删除

firebase_core: ^1.0.3

从您的 pubspec.yaml 中删除 pubspec.lock 然后运行

flutter packages get

然后重新添加

firebase_core: ^1.0.3

然后运行

flutter packages get

以便重新获取与此包相关的文件