Aron
Aron

Reputation: 92

Flutter build fails [Execution failed for task ':firebase_core:compileReleaseJavaWithJavac'.]

I had no issues yesterday, today my build failed for no obvious reasons. And I just upgraded flutter, and other plugins, and I'm still unable to build my current flutter project which uses the following firebase packages

  firebase_auth: ^3.3.14
  firebase_core: ^1.14.1
  firebase_database: ^9.0.11
  cloud_firestore: ^3.1.12

console

   Building with sound null safety 

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:15: error: package io.flutter.embedding.engine.plugins does not exist
import io.flutter.embedding.engine.plugins.FlutterPlugin;
                                          ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:16: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodCall;
                               ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:17: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodChannel;
                               ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:29: error: cannot find symbol
public class FlutterFirebaseCorePlugin implements FlutterPlugin, MethodChannel.MethodCallHandler {
                                                  ^
  symbol: class FlutterPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:29: error: package MethodChannel does not exist
public class FlutterFirebaseCorePlugin implements FlutterPlugin, MethodChannel.MethodCallHandler {
                                                                              ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:47: error: cannot find symbol
  private MethodChannel channel;
          ^
  symbol:   class MethodChannel
  location: class FlutterFirebaseCorePlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:64: error: cannot find symbol
  public void onAttachedToEngine(FlutterPluginBinding binding) {
                                 ^
  symbol:   class FlutterPluginBinding
  location: class FlutterFirebaseCorePlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:71: error: cannot find symbol
  public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
                                            ^
  symbol:   class FlutterPluginBinding
  location: class FlutterFirebaseCorePlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:217: error: cannot find symbol
  public void onMethodCall(MethodCall call, @NonNull final MethodChannel.Result result) {
                           ^
  symbol:   class MethodCall
  location: class FlutterFirebaseCorePlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:217: error: package MethodChannel does not exist
  public void onMethodCall(MethodCall call, @NonNull final MethodChannel.Result result) {
                                                                        ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:63: error: method does not override or implement a method from a supertype
  @Override
  ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:66: error: cannot find symbol
    channel = new MethodChannel(binding.getBinaryMessenger(), CHANNEL_NAME);
                  ^
  symbol:   class MethodChannel
  location: class FlutterFirebaseCorePlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:70: error: method does not override or implement a method from a supertype
  @Override
  ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:216: error: method does not override or implement a method from a supertype
  @Override
  ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.14.1\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java:220: error: illegal parenthesized expression
    switch (call.method) {
           ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
15 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':firebase_core:compileReleaseJavaWithJavac'.
> 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 9s
Running Gradle task 'assembleRelease'...                           11.3s
Gradle task assembleRelease failed with exit code 1

build.gradle

buildscript {
    ext.kotlin_version = '1.6.20'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'

    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':src')
}

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

app/build.gradle

...
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
android {
    compileSdkVersion flutter.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

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

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.XXXXXX"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        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 "com.android.support:multidex:1.0.3"
    implementation "com.google.android.gms:play-services-base:18.0.1"
    implementation platform('com.google.firebase:firebase-bom:29.1.0')

}

Things I have tried:

Thank you for any suggestions

[Update]. The problem seems to be my lib's folder! I had made a change to one of the directory names in the lib folder. And this problem began to appear. Even though I manually updated all package import URIs. Transferring the lib folder into a new project persists the problem, reverting the name changes still has no effect. What am I missing

Error: The argument type 'List<StoreOrderEntity/1/>' can't be assigned to the parameter type 'List<StoreOrderEntity/2/>'.

Execution failed for task ':app:compileFlutterBuildDebug'.

Upvotes: 1

Views: 1301

Answers (1)

ShinMyth
ShinMyth

Reputation: 644

Here's a possible solution to the problem you have before the update on your lib folder. And it is commenting out all firebase code in android/build.gradle and android/app/build.gradle similar to this:

android/build.gradle

enter image description here

android/app/build.gradle

enter image description here

After doing this do a flutter clean just to be safe then a rebuild.

Upvotes: 0

Related Questions