firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.69k stars 3.97k forks source link

🐛 [FlutterFirebaseCorePlugin] Execution failed for task ':firebase_core:compileDebugJavaWithJavac' #3806

Closed LeapingSwan closed 3 years ago

LeapingSwan commented 4 years ago

Bug report

Posted originally as a discussion but now believe this may be a bug so reposting here.

I am having a problem creating a flutter Android build on Visual Studio. I am getting the following error:

Users/xxxxxxxxxxxx/.asdf/installs/flutter/1.12.13+hotfix.7-stable/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.5.0/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.

Please note I have tried using flutter pub cache and then flutter clean.

I believe I have tracked this back to the following line of code line 92 (the fourth line here) in the Java plugin referred to, FlutterFirebaseCorePlugin:

private Task<Map<String, Object>> firebaseAppToMap(FirebaseApp firebaseApp) {
return Tasks.call(
cachedThreadPool,
() -> {
Map<String, Object> appMap = new HashMap<>();
Map<String, String> optionsMap = new HashMap<>();
FirebaseOptions options = firebaseApp.getOptions();
      ………..}

Which seems to suggest that there is something wrong with this plugin.

Thanks for any help and my set up is as described below.

Flutter doctor shows the following:

xxxxxxxxx@xxxxxx-MBP bizbox % ~/.asdf/shims/flutter doctor -v
[✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.6 19G2021, locale en-GB)
• Flutter version 1.22.0 at /Users/stephenswan/.asdf/installs/flutter/1.12.13+hotfix.7-stable
• Framework revision d408d302e2 (8 days ago), 2020-09-29 11:49:17 -0700
• Engine revision 5babba6c4d
• Dart version 2.10.0
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/stephenswan/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0.1, Build version 12A7300
• CocoaPods version 1.9.3
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 49.0.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.49.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.15.0
[✓] Connected device (1 available)
• AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
! Error: xxxxxxxxxx’s iPhone is not connected. Xcode will continue when xxxxxxxxxx’s iPhone is connected.
(code -13)
• No issues found!

Dependencies in pub spec.ymal are as follows:
name: yyyyyyy
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.6.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
permission_handler: 5.0.0+hotfix.10
cupertino_icons: ^0.1.2
pdf: ^1.11.1
path_provider: ^1.6.5
flutter_full_pdf_viewer: ^1.0.6
flutter_email_sender: ^3.0.1
firebase_auth: ^0.18.1+1
cloud_firestore: ^0.14.1+2
provider: ^4.3.2+2
flutter_spinkit: "^4.1.2"
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/

Gradle.properties are:
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
and app/build.gradle is
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 GradleException("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 28
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 "zzzzzz.wwwwww.yyyyyyyyy"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    //Enable multidex by adding this line 

    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"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test🏃1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
apply plugin: 'com.google.gms.google-services'
LeapingSwan commented 4 years ago

Please note I have now successfully built to iOS so this is only a problem with the Android build

darshankawar commented 4 years ago

@LeapingSwan Please provide a minimal complete reproducible code sample. In pubspec.yaml you shared, I don't see firebase_core plugin. Also provide how you are using firebase_core plugin to initialize your project. Thanks.

LeapingSwan commented 4 years ago

Hi @darshankawar thanks for coming back to me.

First that's weird that firebase core was not in there. I may have taken it out temporarily at some point in trying to isolate the problem and copied the file at that point. My apologies. The pubspec.yaml for my own project is currently as follows:

name: xxxxxx
description: A new Flutter project.

version: 1.0.0+1

environment:
  sdk: ">=2.6.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2

  pdf: ^1.11.1
  path_provider: ^1.6.5
  flutter_full_pdf_viewer: ^1.0.6
  flutter_email_sender: ^3.0.1
  firebase_core: ^0.5.0+1
  cloud_firestore: ^0.14.1+2
  firebase_auth: ^0.18.1+2

  provider: ^4.3.2+2
  flutter_spinkit: "^4.1.2"

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:

  uses-material-design: true
  assets:
    - assets/

In terms of code I have continued to experiment to try and isolate the problem and in fact created an entirely fresh project based on the official example on GitHub which is available here:

https://pub.dev/packages/firebase_core/example

This shows the same behaviour with the same error trying to build to the Android Simulator. It (and my own project) does build to iOS fine.

The code for that, including initialisation is as follows:

// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// ignore_for_file: public_member_api_docs

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  final String name = 'foo';
  final FirebaseOptions firebaseOptions = const FirebaseOptions(
    appId: '1:448618578101:ios:0b650370bb29e29cac3efc',
    apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0',
    projectId: 'react-native-firebase-testing',
    messagingSenderId: '448618578101',
  );

  Future<void> initializeDefault() async {
    FirebaseApp app = await Firebase.initializeApp();
    assert(app != null);
    print('Initialized default app $app');
  }

  Future<void> initializeSecondary() async {
    FirebaseApp app =
        await Firebase.initializeApp(name: name, options: firebaseOptions);

    assert(app != null);
    print('Initialized $app');
  }

  void apps() {
    final List<FirebaseApp> apps = Firebase.apps;
    print('Currently initialized apps: $apps');
  }

  void options() {
    final FirebaseApp app = Firebase.app(name);
    final FirebaseOptions options = app?.options;
    print('Current options for app $name: $options');
  }

  Future<void> delete() async {
    final FirebaseApp app = Firebase.app(name);
    await app?.delete();
    print('App $name deleted');
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Firebase Core example app'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(20.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              RaisedButton(
                  onPressed: initializeDefault,
                  child: const Text('Initialize default app')),
              RaisedButton(
                  onPressed: initializeSecondary,
                  child: const Text('Initialize secondary app')),
              RaisedButton(onPressed: apps, child: const Text('Get apps')),
              RaisedButton(
                  onPressed: options, child: const Text('List options')),
              RaisedButton(onPressed: delete, child: const Text('Delete app')),
            ],
          ),
        ),
      ),
    );
  }
}

And my pubspec.yaml for test project is:

name: fbasetest
description: A new Flutter project.

version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.0
  firebase_core: ^0.5.0+1

dev_dependencies:
  flutter_test:
    sdk: flutter

# The following section is specific to Flutter.
flutter:

  uses-material-design: true

This produces the same error as before i.e.:

Launching lib/main.dart on AOSP on IA Emulator in debug mode...
/Users/yyyyyyyyyyyyyy/.asdf/installs/flutter/1.12.13+hotfix.7-stable/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.5.0+1/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 25s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

As per my original post I can see that line of code in the FlutterFirebaseCorePlugin (line 92 in the plugin, line 4 in the snippet below):

private Task<Map<String, Object>> firebaseAppToMap(FirebaseApp firebaseApp) {
return Tasks.call(
cachedThreadPool,
() -> {
Map<String, Object> appMap = new HashMap<>();
Map<String, String> optionsMap = new HashMap<>();
FirebaseOptions options = firebaseApp.getOptions();
      ………..}

I have little knowledge of Java so can't really see if there is a problem there or if it is some sort of version conflict. I believe everything is as up to date as possible.

For completeness I have run flutter doctor again with the following result:

yyyyyyy@yyyyyyy-MacBook-Pro fbasetest % ~/.asdf/shims/flutter doctor -v
[✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.6 19G2021, locale en-GB)
    • Flutter version 1.22.0 at /Users/yyyyyyyyyyy/.asdf/installs/flutter/1.12.13+hotfix.7-stable
    • Framework revision d408d302e2 (2 weeks ago), 2020-09-29 11:49:17 -0700
    • Engine revision 5babba6c4d
    • Dart version 2.10.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/stephenswan/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.50.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.15.0

[✓] Connected device (1 available)
    • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
    ! Error: yyyyyyyy’s iPhone is not connected. Xcode will continue when yyyyyyyy’s iPhone is connected.
      (code -13)

Thanks for your help

TahaTesser commented 4 years ago

Hi @LeapingSwan Following the steps, have no issues with core plugin using an official example and latest `firebase_core: ^0.5.0+1

complete code sample ```dart // Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // ignore_for_file: public_member_api_docs import 'dart:async'; import 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { final String name = 'foo'; final FirebaseOptions firebaseOptions = const FirebaseOptions( appId: '1:448618578101:ios:0b650370bb29e29cac3efc', apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', projectId: 'react-native-firebase-testing', messagingSenderId: '448618578101', ); Future initializeDefault() async { FirebaseApp app = await Firebase.initializeApp(); assert(app != null); print('Initialized default app $app'); } Future initializeSecondary() async { FirebaseApp app = await Firebase.initializeApp(name: name, options: firebaseOptions); assert(app != null); print('Initialized $app'); } void apps() { final List apps = Firebase.apps; print('Currently initialized apps: $apps'); } void options() { final FirebaseApp app = Firebase.app(name); final FirebaseOptions options = app?.options; print('Current options for app $name: $options'); } Future delete() async { final FirebaseApp app = Firebase.app(name); await app?.delete(); print('App $name deleted'); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Firebase Core example app'), ), body: Padding( padding: const EdgeInsets.all(20.0), child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ RaisedButton( onPressed: initializeDefault, child: const Text('Initialize default app')), RaisedButton( onPressed: initializeSecondary, child: const Text('Initialize secondary app')), RaisedButton(onPressed: apps, child: const Text('Get apps')), RaisedButton( onPressed: options, child: const Text('List options')), RaisedButton(onPressed: delete, child: const Text('Delete app')), ], ), ), ), ); } } ```
Launching lib\main.dart on sdk gphone x86 in debug mode...
lib\main.dart:1
√ Built build\app\outputs\flutter-apk\app-debug.apk.
D/HostConnection(27430): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
D/EGL_emulation(27430): eglMakeCurrent: 0xea4a18e0: ver 2 0 (tinfo 0xea7f0070) (first time)
Connecting to VM Service at ws://127.0.0.1:54534/XXFPv3kj_r8=/ws
I/Choreographer(27430): Skipped 61 frames!  The application may be doing too much work on its main thread.
I/flutter (27430): Initialized default app FirebaseApp([DEFAULT])
I/flutter (27430): Initialized FirebaseApp(foo)
I/flutter (27430): Currently initialized apps: [FirebaseApp([DEFAULT]), FirebaseApp(foo)]
I/flutter (27430): Current options for app foo: {apiKey: AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0, appId: 1:448618578101:ios:0b650370bb29e29cac3efc, messagingSenderId: 448618578101, projectId: react-native-firebase-testing, authDomain: null, databaseURL: null, storageBucket: null, measurementId: null, trackingId: null, deepLinkURLScheme: null, androidClientId: null, iosClientId: null, iosBundleId: null, appGroupId: null}
I/flutter (27430): App foo deleted

You might have an issue in your pub cache

/Users/yyyyyyyyyyyyyy/.asdf/installs/flutter/1.12.13+hotfix.7-stable/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.5.0+1/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
LeapingSwan commented 4 years ago

Hi TahaTesser,

Thanks for trying that.

First to confirm I have run Pub Cache repair and flutter clean before doing new builds.

Since the same code produces the error for me I believe it may be something to do with my setup, although everything else works fine. Since it works for iOS I think it's a problem with something in the Android setup. Could you please confirm what Android and Java JDK you used? Mine are as shown in the flutter doctor output (copied again below) so any differences you can see would be appreciated or if you can give me a print of your own flutter doctor I can try and match that.

Thanks

yyyyyyy@yyyyyyy-MacBook-Pro fbasetest % ~/.asdf/shims/flutter doctor -v [✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.6 19G2021, locale en-GB) • Flutter version 1.22.0 at /Users/yyyyyyyyyyy/.asdf/installs/flutter/1.12.13+hotfix.7-stable • Framework revision d408d302e2 (2 weeks ago), 2020-09-29 11:49:17 -0700 • Engine revision 5babba6c4d • Dart version 2.10.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/stephenswan/Library/Android/sdk • Platform android-30, build-tools 30.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.0.1, Build version 12A7300 • CocoaPods version 1.9.3

[✓] Android Studio (version 4.0) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 50.0.1 • Dart plugin version 193.7547 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.50.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.15.0

[✓] Connected device (1 available) • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator) ! Error: yyyyyyyy’s iPhone is not connected. Xcode will continue when yyyyyyyy’s iPhone is connected. (code -13)

TahaTesser commented 4 years ago

Hi @LeapingSwan That's my bad, i should have posted my flutter doctor -v output as well

flutter doctor -v ```bash [✓] Flutter (Channel master, 1.24.0-2.0.pre.98, on Microsoft Windows [Version 10.0.19041.572], locale en-US) • Flutter version 1.24.0-2.0.pre.98 at C:\Code\flutter_master • Framework revision a4ac7cce82 (4 hours ago), 2020-10-21 00:46:59 -0400 • Engine revision c2c74ed708 • Dart version 2.11.0 (build 2.11.0-240.0.dev) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at C:\Code\sdk • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = C:\Code\sdk • Java binary at: C:\Code\android-studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted. [✓] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.6) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.7.30611.23 • Windows 10 SDK version 10.0.18362.0 [✓] Android Studio (version 4.1.0) • Android Studio at C:\Code\android-studio • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) [✓] VS Code (version 1.50.1) • VS Code at C:\Users\Taha\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.15.1 [✓] Connected device (5 available) • sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19041.572] • Web Server (web) • web-server • web-javascript • Flutter Tools • Chrome (web) • chrome • web-javascript • Google Chrome 86.0.4240.111 • Edge (web) • edge • web-javascript • Microsoft Edge 86.0.622.48 • No issues found! ```
google-oss-bot commented 4 years ago

Hey @LeapingSwan. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

LeapingSwan commented 4 years ago

Hi, this issue is still unresolved for me.

I have compared the flutter doctor outputs but can see no difference (very minor differences on JDK release numbers but same version). I have tried updating to Android Studio 4.1 but that did not help so really at a loss. I'm not sure what additional information I could supply to give greater insight. On one level, as no one else seems to be having this problem, it looks like some sort of problem with my Android set up but I can't identify what. On another level the error reporting is taking me to a line of code in the Java update (as reported in my earlier comments) that does not seem to work though I can't see why (again not a Java expert by any means). I could really do with getting to the bottom of this as currently I cannot build for Android when I am using Firebase Core. It does work fine without Firebase Core.

Is there anyway to get this resolved?

Thanks

Stephen

mohamadhadibi commented 3 years ago

I have the same problem. it is ok on iOS but on android keep showing this error Execution failed for task ':firebase_core:compileDebugJavaWithJavac'.

Could not resolve all files for configuration ':firebase_core:debugCompileClasspath'. Could not find lifecycle-runtime-2.0.0.jar (androidx.lifecycle:lifecycle-runtime:2.0.0). Searched in the following locations: https://dl.google.com/dl/android/maven2/androidx/lifecycle/lifecycle-runtime/2.0.0/lifecycle-runtime-2.0.0.jar

Possible solution:

after I upgrade my flutter on beta channel to Flutter 1.25.0-8.1.pre • channel beta • https://github.com/flutter/flutter.git Framework • revision 8f89f6505b (12 days ago) • 2020-12-15 15:07:52 -0800 Engine • revision 92ae191c17 Tools • Dart 2.12.0 (build 2.12.0-133.2.beta)

balajijayabal commented 3 years ago

I am also getting the same problem. Did anyone resolved it already ? Please suggest.

LeapingSwan commented 3 years ago

Hi @balajijayabal,

Because of this issue I have been focusing on the iOS version of my App and doing my development there, hoping that an update of Android Studio might solve this problem at some point. I have however just tried the Android simulator to see if it's still there.

I tried initially without an update to Android Studio and got a string of errors where some files were not being found. I took a look at the suggested possible solution that @mohamadhadibi suggested and this did seem to refer to Mavern files as indicated in that documentation and the error messages I was getting at that point. I can't pretend I understand yet how to apply that documentation to my situation and will either have to hope that someone with more knowledge can more specifically explain how to use that or when I can I'll have to spend some time trying to understand it.

However before going any further I did an Android Studio update to the latest version as of today (not the Beta channel version) and now I'm back to a similar problem as posted in my original message i.e the error I get is:

/Users/[xxxxxxxxx]/.asdf/installs/flutter/1.12.13+hotfix.7-stable/.pub-cache/hosted/pub.dartlang.org/camera-0.5.8+11/android/src/main/java/io/flutter/plugins/camera/CameraPermissions.java:36: error: cannot find symbol (String errorCode, String errorDescription) -> { ^ 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.

Note though that this relates to Camera permissions and not firebase. I have added in camera permissions since initially raising this post so at least initially it seems to be tripping on that rather than firebase. Both work fine on the iOS version.

If anyone can suggest anything specific for me to try and solve this problem I'm happy to give it a go.

Thanks

Stephen

amarchenko25 commented 3 years ago

Hi @LeapingSwan, I faced with exact same issue. Try to update the Android Gradle plugin. This helped me :) 1) open /android folder through Android Studio 2) you would see something like that, click update. Screen Shot 2021-03-15 at 10 13 43 PM

ir2pid commented 3 years ago

I'm facing the same issue, but works on one mac and doesn't on another.

`sdk/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.5.0+1/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.

russellwheatley commented 3 years ago

Hey @LeapingSwan, have you tried this suggestion?

LeapingSwan commented 3 years ago

Hi @russellwheatley yes I have tried this, making sure all plugins are fully up to date but no success.

In fact since my original post I had a major laptop crash when updating to Big Sur OS with the result that I have completely re-built the laptop software and re-installed Flutter/ Android Studio etc. I brought the project across from a backup but only the code etc. - all the platforms were newly installed on the rebuild a few weeks ago and updated again this morning and I'm still getting exactly the same error on Android although building to iOS is fine. As originally reported that was also true on the official example. That leaves me thinking there is something in my project settings (across all projects) but no idea where to look for that.

Thanks

ronky commented 3 years ago

Hi @LeapingSwan I am facing the same issue. I have installed Android Studio over snap and I am gonna try to install it as standalone. Did you try installing it without Snap too?

ronky commented 3 years ago

Hi @LeapingSwan I am facing the same issue. I have installed Android Studio over snap and I am gonna try to install it as standalone. Did you try installing it without Snap too?

I have tried it and it did not help.

ronky commented 3 years ago

Hi @LeapingSwan I am facing the same issue. I have installed Android Studio over snap and I am gonna try to install it as standalone. Did you try installing it without Snap too?

I have tried it and it did not help.

...and i also tried reinstalling flutter to a standalone installation instead of snap. same result.

LeapingSwan commented 3 years ago

Hi @ronky , I have not used Snap at all. I have simply downloaded Android Studio .dmg (I am working on a Mac) and installed from there.

One thing to make clear my initial install of Android Studio, probably about a year ago, worked fine and built without a problem. I was mainly working on iOS so not sure when the problem was actually introduced. It may have been when I started adding some of the plugins or it may have been after an update of some of my software platforms.

ronky commented 3 years ago

@LeapingSwan the only workaround my colleague found so far, is let the app run in the web browser. But that poses other problems down the road... Any successes on your side?

LeapingSwan commented 3 years ago

Hi @ronky yes running in a browser would not do it for me - really need to test and publish on the simulator/ device but currently can't build for Android at all.

It's clearly not just me experiencing this but presumably most people are not having this problem or it would be a much bigger issue and get attention as it is a complete stop for those of us having to deal with it.

Really not sure what the magic difference is and apart from responses on this thread I seem to be waiting for it to get fixed as part of an update of Flutter but don't know when that might be. For the time being I keep working on iOS but will need to publish to Android eventually.

@markusaksli-nc why did you remove the 'Needs Attention' label as this is still unresolved and needs a solution. Are you able to get someone suitable to look at it?

ronky commented 3 years ago

@LeapingSwan I completely reinstalled Ubuntu and set up the environment from scratch and... it runs. So it must be some kind of a config issue and unrelated to the firebase core I guess.

LeapingSwan commented 3 years ago

Hi @ronky great to hear you have got past this issue.

I'm not using ubuntu (unless it's somewhere in the background of something else I have installed - I'm a self taught part time developer so don't really have great depth to areas outside where I have needed to focus). My development environment is a MacBook Pro. As mentioned in an earlier post I have completely rebuilt the machine a few weeks ago for a different reason and freshly installed flutter from scratch but that has not worked for me.

I have tried again this morning (there is a Flutter upgrade in waiting but I have not done that yet as want to get something else working in my app before I make any changes to the environment at all) and it has still not worked for Android. The error I get is as follows:

Execution failed for task ':camera:compileDebugJavaWithJavac'.

Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

That is falling over at the same point but the message seems slightly different so I'll explore that in due course. I do need to keep focusing on the iOS version at the moment. Once I have that completed I'll come back to getting g the Android version working.

Thanks

Stephen

russellwheatley commented 3 years ago

Hey @LeapingSwan, I don't believe your error is an issue with the Flutterfire library. I did a quick google search of your error and up popped this thread on StackOverflow with the exact error you pasted:

Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

In a nutshell; you need to either install Java developer kit (JDK) and add to your path, or you need to make your existing JDK path visible on your path. Or update your gradle setup in your android project to point to your JDK. Either way, there are plenty of resources online to help you get setup. Hope this helps.

LeapingSwan commented 3 years ago

Hi @russellwheatley , thanks for your comments.

As per my earlier posts the JDK was installed and Flutter doctor was showing everything was ok. Like you I did at points suspect that there was a problem with the set up as I have mentioned before but I could not find what it was and as per one of my original posts the error that was being thrown up could be traced back to failing at a line of code in the Java plugin (so it was seeing and accessing the plugin). I'm not sure that thread you linked to, whilst similar, actually related to the same issue. Because I did suspect it might be a set up issue I spent many hours looking at that possibility and following up various pieces of guidance on how to install the Java plugin and setup Android Studio. But this at least started off as seeing the Java code and failing. As per my original post:

"I believe I have tracked this back to the following line of code line 92 (the fourth line here) in the Java plugin referred to, FlutterFirebaseCorePlugin:

private Task<Map<String, Object>> firebaseAppToMap(FirebaseApp firebaseApp) { return Tasks.call( cachedThreadPool, () -> { Map<String, Object> appMap = new HashMap<>(); Map<String, String> optionsMap = new HashMap<>(); FirebaseOptions options = firebaseApp.getOptions(); ………..}"

The good news is that I did an update of Flutter this morning and an update of Android Studio recently (to 4.2) & updated the JDK, as well as checking again that all of my dependencies are up to date, and it now builds fine. Really not sure which of those updates fixed the problem but I do seem to have got past it. Perhaps this has fixed whatever problem I had with setup or there has been an unintentional fixe via the plugin.

For anyone else coming to this thread I have posted below my flutter doctor so it can be seen what the status was when it did work.

Thanks for your help.

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.2.3 20D91 darwin-x64, locale en-GB) • Flutter version 2.2.3 at /Users/xxxxxxxxxxxx/development/flutter • Framework revision f4abaa0735 (11 days ago), 2021-07-01 12:46:11 -0700 • Engine revision 241c87ad80 • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/xxxxxxxxxxxx/Library/Android/sdk • Platform android-30, build-tools 30.0.3 • ANDROID_HOME = /Users/xxxxxxxxxxxx/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.5, Build version 12E262 • CocoaPods version 1.10.1

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] VS Code (version 1.58.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.24.0

[✓] Connected device (2 available) • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114

russellwheatley commented 3 years ago

Thanks for the detailed response, I am glad that it has now been resolved 👍