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.65k stars 3.96k forks source link

🐛 Crashlytics Build fails with uploadCrashlyticsMappingFileRelease problem #6705

Closed SimonErich closed 3 years ago

SimonErich commented 3 years ago

Bug report

Describe the bug When I try to bundle my application for production on android, I get the following error message:

flutter build appbundle

💪 Building with sound null safety 💪

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':app:uploadCrashlyticsMappingFileRelease' (type 'UploadMappingFileTask').
  - Type 'com.google.firebase.crashlytics.buildtools.gradle.tasks.UploadMappingFileTask' property 'googleServicesFile' specifies file '/home/Flutters/demoapp/build/app/generated/res/google-services/release/values/values.xml' which doesn't exist.

    Reason: An input file was expected to be present but it doesn't exist.

    Possible solutions:
      1. Make sure the file exists before the task is called.
      2. Make sure that the task which produces the file is declared as an input.

    Please refer to https://docs.gradle.org/7.0.2/userguide/validation_problems.html#input_file_does_not_exist for more details about this problem.

* 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

This is my app/bundle.gradle file:

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: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

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

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 30

    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.demo.my"
        minSdkVersion 19
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
    }
    buildTypes {
       release {
           signingConfig signingConfigs.release
       }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'
}

Expected behavior

It is expected to create that file and upload it correctly, thereby finishing the bundle build.

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel master, 2.4.0-5.0.pre.87, on Fedora 34 (Workstation Edition) 5.12.15-300.fc34.x86_64, locale en_GB.UTF-8) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Chrome - develop for the web [✓] Android Studio (version 4.1) [✓] VS Code (version 1.58.2) [✓] Connected device (3 available) • No issues found! ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` flutter pub deps -- --style=compact Dart SDK 2.14.0-321.0.dev Flutter SDK 2.4.0-5.0.pre.87 mydemo 1.0.1+10 dependencies: - app_code 0.0.1 [flutter intl marqably_firebase] - app_layout 0.0.1 [flutter flutter_svg app_code toolkit marqably_content_fragments gemplus_townwatch flutter_html ionicons flutter_hooks custom_navigation_bar table_calendar get_it package_info_plus url_launcher] - built_value 8.0.6 [built_collection collection fixnum] - cupertino_icons 1.0.3 - custom_navigation_bar 0.8.2 [flutter] - ferry 0.10.3 [gql rxdart gql_link gql_exec meta collection hive built_value ferry_exec normalize ferry_cache] - ferry_flutter 0.5.3 [ferry gql_exec ferry_exec flutter flutter_test] - ferry_graphql_lighthouse 0.0.1 [built_value flutter intl] - ferry_hive_store 0.4.3 [hive ferry_store rxdart collection] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_form_builder 6.0.1 [flutter flutter_localizations intl collection] - flutter_hooks 0.18.0 [flutter] - flutter_html 2.1.0 [html csslib flutter_layout_grid video_player chewie webview_flutter chewie_audio flutter_svg flutter_math_fork collection numerus flutter] - flutter_mobx 2.0.0 [flutter mobx] - flutter_svg 0.22.0 [flutter meta path_drawing vector_math xml] - gemplus_about 0.0.1 [flutter i18n_extension flutter_html flutter_hooks share ionicons app_layout app_code ferry_graphql_hooks ferry_graphql_lighthouse marqably_content_fragments toolkit marqably_firebase url_launcher flutter_pdfview path_provider maps_launcher] - gemplus_clubs 0.0.1 [flutter i18n_extension flutter_html flutter_hooks share ionicons app_layout app_code ferry_graphql_hooks ferry_graphql_lighthouse toolkit url_launcher] - gemplus_garbagecalendar 0.0.1 [flutter i18n_extension flutter_html flutter_hooks share ionicons app_layout app_code ferry_graphql_hooks ferry_graphql_lighthouse toolkit marqably_local_notifications url_launcher hive hive_flutter get_it flutter_form_builder hooks_riverpod mobx flutter_mobx mobx_codegen] - gemplus_townwatch 0.0.1 [flutter i18n_extension flutter_hooks app_layout app_code ferry_graphql_hooks ferry_graphql_lighthouse marqably_classified toolkit flutter_form_builder form_builder_image_picker] - get_it 7.2.0 [async collection] - gql_http_link 0.4.0 [meta gql gql_exec gql_link http http_parser] - gql_link 0.4.0 [meta gql gql_exec] - hive 2.0.4 [meta crypto] - hive_flutter 1.1.0 [flutter hive path_provider path] - hooks_riverpod 1.0.0-dev.5 [collection flutter flutter_hooks flutter_riverpod riverpod state_notifier] - i18n_extension 4.1.0 [sprintf args analyzer gettext_parser equatable flutter] - ionicons 0.1.2 [flutter] - maps_launcher 2.0.0 [flutter flutter_web_plugins url_launcher] - marqably_blog 0.0.1 [flutter i18n_extension flutter_html flutter_hooks share ionicons app_layout app_code ferry_graphql_hooks ferry_graphql_lighthouse toolkit] - marqably_classified 0.0.1 [flutter i18n_extension flutter_html flutter_hooks share ionicons app_layout app_code ferry_graphql_hooks ferry_graphql_lighthouse toolkit url_launcher flutter_form_builder form_builder_image_picker] - marqably_content_fragments 0.0.1 [flutter i18n_extension flutter_hooks app_layout app_code ferry_graphql_hooks ferry_graphql_lighthouse toolkit] - marqably_events 0.0.1 [flutter i18n_extension flutter_html flutter_hooks share ionicons app_layout app_code ferry_graphql_hooks ferry_graphql_lighthouse toolkit flutter_calendar_carousel badges add_2_calendar] - marqably_firebase 0.0.1 [flutter i18n_extension flutter_hooks firebase_messaging firebase_core firebase_analytics firebase_crashlytics firebase_performance firebase_remote_config firebase_dynamic_links get_it toolkit] - marqably_local_notifications 0.0.1 [flutter flutter_hooks flutter_local_notifications toolkit app_layout get_it] - marqably_weather 0.0.1 [flutter i18n_extension flutter_hooks app_layout app_code ferry_graphql_hooks ferry_graphql_lighthouse toolkit weather_icons] - mobx 2.0.1 [meta] - mobx_codegen 2.0.1+3 [analyzer build build_resolvers meta mobx path source_gen] - pedantic 1.11.0 - share 2.0.4 [meta mime flutter] - toolkit 0.0.1 [flutter app_code marqably_firebase ionicons flutter_form_builder share] dev dependencies: - build_runner 1.12.2 [args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style glob graphs http_multi_server io js logging meta mime path pedantic pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - ferry_generator 0.4.0-nullsafety.1 [gql gql_build gql_code_builder built_collection code_builder build path ferry_exec] - flutter_lints 1.0.3 [lints] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] - gql_build 0.2.0-nullsafety.0 [analyzer build built_collection built_value built_value_generator code_builder dart_style glob gql gql_code_builder path yaml] - gql_code_builder 0.2.0-nullsafety.0 [analyzer built_collection built_value code_builder collection gql gql_exec path recase] transitive dependencies: - _fe_analyzer_shared 22.0.0 [meta] - add_2_calendar 2.1.0 [flutter] - analyzer 1.7.0 [_fe_analyzer_shared cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml pedantic] - args 2.1.1 - async 2.7.0 [collection meta] - badges 2.0.1 [flutter] - boolean_selector 2.1.0 [source_span string_scanner] - build 2.0.2 [analyzer async convert crypto glob logging meta path] - build_config 0.4.7 [checked_yaml json_annotation meta path pubspec_parse yaml] - build_daemon 2.1.10 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.0.3 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 6.1.12 [async build build_config build_resolvers collection convert crypto glob graphs logging meta path package_config pedantic pool timing watcher yaml] - built_collection 5.1.0 - built_value_generator 8.0.6 [analyzer build build_config built_collection built_value source_gen quiver] - characters 1.1.0 - charcode 1.3.1 - checked_yaml 2.0.1 [json_annotation source_span yaml] - chewie 1.2.2 [cupertino_icons flutter provider video_player wakelock] - chewie_audio 1.2.0 [cupertino_icons flutter video_player] - cli_util 0.3.0 [meta path] - clock 1.1.0 - code_builder 3.7.0 [built_collection built_value collection matcher meta] - collection 1.15.0 - convert 3.0.0 [typed_data] - crypto 3.0.1 [collection typed_data] - csslib 0.17.0 [source_span] - dart_style 2.0.1 [analyzer args path pub_semver source_span] - equatable 2.0.3 [collection meta] - fake_async 1.2.0 [clock collection] - ferry_cache 0.5.4 [ferry_exec meta rxdart normalize ferry_store collection] - ferry_exec 0.1.3 [gql gql_exec gql_link meta async collection] - ferry_graphql_hooks 0.0.1 [flutter ferry flutter_hooks get_it ferry_exec gql_exec] - ferry_store 0.4.3 [rxdart collection] - ffi 1.1.2 - file 6.1.2 [meta path] - firebase 9.0.1 [http http_parser js] - firebase_analytics 8.1.2 [firebase_analytics_platform_interface firebase_analytics_web firebase_core flutter meta] - firebase_analytics_platform_interface 2.0.1 [flutter meta] - firebase_analytics_web 0.3.0+1 [firebase firebase_analytics_platform_interface flutter flutter_web_plugins meta] - firebase_core 1.4.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics 2.0.7 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_crashlytics_platform_interface 3.0.6 [collection firebase_core flutter meta plugin_platform_interface] - firebase_dynamic_links 2.0.7 [firebase_core flutter] - firebase_messaging 10.0.3 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_messaging_platform_interface 3.0.2 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.0.2 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_performance 0.7.0+6 [firebase_core flutter] - firebase_remote_config 0.10.0+3 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface flutter] - firebase_remote_config_platform_interface 0.3.0+3 [firebase_core flutter meta plugin_platform_interface] - fixnum 1.0.0 - flutter_calendar_carousel 2.0.1 [intl flutter] - flutter_layout_grid 1.0.1 [flutter collection meta quiver] - flutter_local_notifications 6.0.0 [flutter flutter_local_notifications_platform_interface platform timezone] - flutter_local_notifications_platform_interface 4.0.0 [flutter plugin_platform_interface] - flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math] - flutter_math_fork 0.3.3 [flutter flutter_svg provider meta collection tuple] - flutter_pdfview 1.1.0 [flutter] - flutter_plugin_android_lifecycle 2.0.2 [flutter] - flutter_riverpod 1.0.0-dev.5 [collection flutter meta riverpod state_notifier] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - form_builder_image_picker 1.0.0-nullsafety.0 [flutter flutter_form_builder image_picker image_picker_for_web http] - freezed_annotation 0.14.2 [collection json_annotation meta] - gettext_parser 0.2.0 - glob 2.0.1 [async collection file path pedantic string_scanner] - gql 0.13.0 [collection meta source_span] - gql_exec 0.3.0 [collection meta gql] - graphs 1.0.0 - html 0.15.0 [csslib source_span] - http 0.13.3 [async http_parser meta path pedantic] - http_multi_server 3.0.1 [async] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image_picker 0.7.5+4 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface image_picker_for_web] - image_picker_for_web 2.0.0 [image_picker_platform_interface meta flutter flutter_web_plugins] - image_picker_platform_interface 2.1.0 [flutter meta http plugin_platform_interface] - intl 0.17.0 [clock path] - io 1.0.0 [meta path string_scanner] - js 0.6.3 - json_annotation 4.0.1 - lints 1.0.1 - logging 1.0.1 - matcher 0.12.10 [stack_trace] - meta 1.7.0 - mime 1.0.0 - nested 1.0.0 [flutter] - normalize 0.5.4 [gql collection] - numerus 1.1.1 - package_config 2.0.0 [path] - package_info_plus 1.0.3 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web] - package_info_plus_linux 1.0.2 [package_info_plus_platform_interface flutter path] - package_info_plus_macos 1.1.1 [flutter] - package_info_plus_platform_interface 1.0.1 [flutter meta plugin_platform_interface] - package_info_plus_web 1.0.2 [http package_info_plus_platform_interface flutter flutter_web_plugins meta] - package_info_plus_windows 1.0.2 [package_info_plus_platform_interface ffi flutter win32] - path 1.8.0 - path_drawing 0.5.1 [vector_math meta path_parsing flutter] - path_parsing 0.2.1 [vector_math meta] - path_provider 2.0.2 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 2.0.0 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.1 [path_provider_platform_interface meta path flutter ffi win32] - petitparser 4.2.0 [meta] - platform 3.0.0 - plugin_platform_interface 2.0.0 [meta] - pool 1.5.0 [async stack_trace] - process 4.2.1 [file path platform] - provider 5.0.0 [collection flutter nested] - pub_semver 2.0.0 [collection] - pubspec_parse 1.0.0 [checked_yaml collection json_annotation pub_semver yaml] - quiver 3.0.1 [matcher] - recase 4.0.0 - riverpod 1.0.0-dev.5 [collection freezed_annotation meta state_notifier] - rxdart 0.27.1 - shelf 1.1.4 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.1 [shelf stream_channel web_socket_channel] - simple_gesture_detector 0.2.0 [flutter] - sky_engine 0.0.99 - source_gen 1.0.2 [analyzer async build dart_style glob meta path pedantic source_span yaml] - source_span 1.8.1 [collection path term_glyph] - sprintf 6.0.0 - stack_trace 1.10.0 [path] - state_notifier 0.7.0 [meta] - stream_channel 2.1.0 [async] - stream_transform 2.0.0 - string_scanner 1.1.0 [charcode source_span] - table_calendar 3.0.1 [flutter intl simple_gesture_detector] - term_glyph 1.2.0 - test_api 0.4.2 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timezone 0.7.0 [path] - timing 1.0.0 [json_annotation] - tuple 2.0.0 [quiver] - typed_data 1.3.0 [collection] - url_launcher 6.0.9 [flutter meta url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - url_launcher_linux 2.0.0 [flutter] - url_launcher_macos 2.0.0 [flutter] - url_launcher_platform_interface 2.0.3 [flutter plugin_platform_interface] - url_launcher_web 2.0.1 [flutter flutter_web_plugins meta url_launcher_platform_interface] - url_launcher_windows 2.0.0 [flutter] - vector_math 2.1.0 - video_player 2.1.6 [flutter flutter_test meta video_player_platform_interface video_player_web] - video_player_platform_interface 4.1.0 [flutter meta flutter_test] - video_player_web 2.0.1 [flutter flutter_web_plugins meta video_player_platform_interface] - wakelock 0.5.2 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows] - wakelock_macos 0.1.0+1 [flutter flutter_web_plugins wakelock_platform_interface] - wakelock_platform_interface 0.2.1+1 [flutter meta] - wakelock_web 0.2.0+1 [flutter flutter_web_plugins js wakelock_platform_interface] - wakelock_windows 0.1.0 [flutter wakelock_platform_interface win32] - watcher 1.0.0 [async path pedantic] - weather_icons 3.0.0-nullsafety.0 [flutter] - web_socket_channel 2.1.0 [async crypto stream_channel] - webview_flutter 2.0.8 [flutter] - win32 2.1.5 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.1.2 [collection meta petitparser] - yaml 3.1.0 [collection source_span string_scanner] ```

markusaksli-nc commented 3 years ago

Hi @SimonErich Does this issue not occur when you run a debug build? Have you completed all of the setup steps? https://firebase.flutter.dev/docs/installation/android https://firebase.flutter.dev/docs/crashlytics/overview#3-platform-integration Thank you

SimonErich commented 3 years ago

@markusaksli-nc thanks for getting back to me. No it does not happen on debug and I followed everything, apart from the simulator setup. The google-services.json is in android/app/ folder.

markusaksli-nc commented 3 years ago

Have you tried moving

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

to the bottom of your build.gradle?

It seems like this can be caused in some order of operations issue in gradle.

SimonErich commented 3 years ago

I have tried that already. Doesn't work either. Same result.

markusaksli-nc commented 3 years ago

I can't really read from the error what exactly is going wrong here so labeling this for further investigation.

whiplashoo commented 3 years ago

Had the exact same issue. Fixed by moving the two plugin directives for Google services and Crashlytics to the end of the file, as @markusaksli-nc suggested. However, it could also be that I had a flaky internet connection when I was receiving these build errors, so that may have been the cause of the issue.

Anyway, here is my 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 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"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 30

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

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.whidev.m"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 45
        versionName "3.3.0"
        multiDexEnabled true
    }

    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
SimonErich commented 3 years ago

I think I have found the problem. I was using an old version of crashlytics form the docs.

I have changed my project build.gradle to use:

        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'

instead of:

        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.1'

and now it works.