Error I am getting in flutter project, when run for android ( real device (android version 10) and simulator ), IOS app works fine, please Help,
i am using M2 chip mac mini 2023.
bellow is a error i am getting on run time, i have tried diffrent verions of kotlin_version, https://services.gradle.org/distributions/gradle-7.5-all.zip, nothing works
How to fix this
e: file:///Volumes/New%20Volume/myapp/android/app/src/main/kotlin/com/shop_app/Application.kt:6:27 Unresolved reference: firebasemessaging
e: file:///Volumes/New%20Volume/myapp/android/app/src/main/kotlin/com/shop_app/Application.kt:7:27 Unresolved reference: firebasemessaging
e: file:///Volumes/New%20Volume/myapp/android/app/src/main/kotlin/com/shop_app/Application.kt:12:9 Unresolved reference: FlutterFirebaseMessagingService
e: file:///Volumes/New%20Volume/myapp/android/app/src/main/kotlin/com/shop_app/Application.kt:26:13 Unresolved reference: FirebaseMessagingPlugin
e: file:///Volumes/New%20Volume/myapp/android/app/src/main/kotlin/com/shop_app/Application.kt:6:27 Unresolved reference: firebasemessaging
e: file:///Volumes/New%20Volume/myapp/android/app/src/main/kotlin/com/shop_app/Application.kt:7:27 Unresolved reference: firebasemessaging
e: file:///Volumes/New%20Volume/myapp/android/app/src/main/kotlin/com/shop_app/Application.kt:12:9 Unresolved reference: FlutterFirebaseMessagingService
e: file:///Volumes/New%20Volume/myapp/android/app/src/main/kotlin/com/shop_app/Application.kt:26:13 Unresolved reference: FirebaseMessagingPlugin
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more 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.gradle in android/app/
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.myapp12345"
minSdkVersion 21
targetSdkVersion 33
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Build.gradle in android/
buildscript {
ext.kotlin_version = '1.8.20'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
//classpath 'com.android.tools.build:gradle:3.5.3' 1.3.50 ext.kotlin_version = '1.8.21'
//classpath 'com.android.tools.build:gradle:3.4.3'
//classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.android.tools.build:gradle:7.4.1'
//classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:+'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
gradle.wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionUrl=https://services.gradle.org/distributions/gradle-7.5-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Flutter doctor logs
flutter doctor -v
[✓] Flutter (Channel stable, 3.13.3, on macOS 13.4.1 22F82 darwin-arm64, locale en-IN)
• Flutter version 3.13.3 on channel stable at /Users/surjitsingh.../Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2524052335 (4 days ago), 2023-09-06 14:32:31 -0700
• Engine revision b8d35810e9
• Dart version 3.1.1
• DevTools version 2.25.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /Users/surjitsingh.../Library/Android/sdk
• Platform android-33, build-tools 33.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.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 17.0.6+0-17.0.6b802.4-9586694)
[✓] VS Code (version 1.82.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (3 available)
• CPH1823 (mobile) • GYRO4SBMUGSCW8VK • android-arm64 • Android 10 (API 29)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.4.1 22F82 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 116.0.5845.179
[✓] Network resources
• All expected network resources are available.
• No issues found!
More Logs, if somebody can help
flutter pub deps — –style=compact
Dart SDK 3.1.1
Flutter SDK 3.13.3
myapp 3.8.8+107
dependencies:
- cached_network_image 3.2.3 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web]
- cupertino_icons 1.0.6
- dio 5.3.2 [async http_parser meta path]
- firebase_core 2.15.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_database 10.2.5 [firebase_core firebase_core_platform_interface firebase_database_platform_interface firebase_database_web flutter]
- firebase_messaging 14.6.7 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- firebase_messaging_platform_interface 4.5.6 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 3.5.6 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math web sky_engine]
- flutter_app_badger 1.5.0 [flutter]
- flutter_cache_manager 3.3.1 [clock collection file flutter http path path_provider rxdart sqflite uuid]
- flutter_inappwebview 5.7.2+3 [flutter]
- flutter_local_notifications 15.1.1 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone]
- flutter_native_image 0.0.6+1 [flutter]
- flutter_slidable 3.0.0 [flutter]
- flutter_svg 2.0.7 [flutter vector_graphics vector_graphics_codec vector_graphics_compiler]
- fluttertoast 8.2.2 [flutter flutter_web_plugins]
- get_it 7.6.4 [async collection]
- http 1.1.0 [async http_parser meta]
- image 4.0.17 [archive meta xml]
- image_cropper 5.0.0 [flutter image_cropper_platform_interface image_cropper_for_web]
- image_picker 1.0.4 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_linux image_picker_macos image_picker_platform_interface image_picker_windows]
- intl 0.18.1 [clock meta path]
- loading_overlay 0.3.0 [flutter]
- meta 1.9.1
- path_provider 2.1.1 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- permission_handler 10.4.5 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface]
- provider 6.0.5 [collection flutter nested]
- rflutter_alert 2.0.7 [flutter]
- rounded_loading_button 2.1.0 [flutter rxdart]
- rxdart 0.27.7
- shared_preferences 2.2.1 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- sqflite 2.3.0 [flutter sqflite_common path]
- webview_flutter 4.2.4 [flutter webview_flutter_android webview_flutter_platform_interface webview_flutter_wkwebview]
- xdg_directories 1.0.3 [meta path]
- xml 6.3.0 [collection meta petitparser]
dev dependencies:
- async 2.11.0 [collection meta]
- drive 1.0.0-1.0.nullsafety.5 [test_api flutter_test flutter_driver stack_trace flutter]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math async boolean_selector characters collection material_color_utilities meta source_span stream_channel string_scanner term_glyph web]
- mockito 5.4.2 [analyzer build code_builder collection dart_style matcher meta path source_gen test_api]
- test 1.24.3 [analyzer async boolean_selector collection coverage http_multi_server io js node_preamble package_config path pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core matcher]
transitive dependencies:
- _fe_analyzer_shared 61.0.0 [meta]
- _flutterfire_internals 1.3.5 [collection firebase_core firebase_core_platform_interface flutter meta]
- analyzer 5.13.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- archive 3.3.9 [crypto path pointycastle]
- args 2.4.2
- boolean_selector 2.1.1 [source_span string_scanner]
- build 2.4.1 [analyzer async convert crypto glob logging meta package_config path]
- built_collection 5.1.1
- built_value 8.6.2 [built_collection collection fixnum meta]
- cached_network_image_platform_interface 2.0.0 [flutter flutter_cache_manager]
- cached_network_image_web 1.0.2 [flutter flutter_cache_manager cached_network_image_platform_interface]
- characters 1.3.0
- clock 1.1.1
- code_builder 4.6.0 [built_collection built_value collection matcher meta]
- collection 1.17.2
- convert 3.1.1 [typed_data]
- coverage 1.6.3 [args logging package_config path source_maps stack_trace vm_service]
- cross_file 0.3.3+5 [js meta]
- crypto 3.0.3 [typed_data]
- dart_style 2.3.2 [analyzer args path pub_semver source_span]
- dbus 0.7.8 [args ffi meta xml]
- fake_async 1.3.1 [clock collection]
- ffi 2.1.0
- file 6.1.4 [meta path]
- file_selector_linux 0.9.2+1 [cross_file file_selector_platform_interface flutter]
- file_selector_macos 0.9.3+2 [cross_file file_selector_platform_interface flutter]
- file_selector_platform_interface 2.6.1 [cross_file flutter http plugin_platform_interface]
- file_selector_windows 0.9.3+1 [cross_file file_selector_platform_interface flutter]
- firebase_core_web 2.7.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_database_platform_interface 0.2.5+5 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_database_web 0.2.3+5 [firebase_core firebase_core_web firebase_database_platform_interface flutter flutter_web_plugins js]
- fixnum 1.1.0
- flutter_blurhash 0.7.0 [flutter]
- flutter_driver 0.0.0 [file flutter flutter_test fuchsia_remote_debug_protocol path meta vm_service webdriver async boolean_selector characters clock collection matcher material_color_utilities platform process source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api vector_math web]
- flutter_local_notifications_linux 4.0.0+1 [dbus ffi flutter flutter_local_notifications_platform_interface path xdg_directories]
- flutter_local_notifications_platform_interface 7.0.0+1 [flutter plugin_platform_interface]
- flutter_plugin_android_lifecycle 2.0.16 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math web]
- frontend_server_client 3.2.0 [async path]
- fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform]
- glob 2.1.2 [async collection file path string_scanner]
- http_multi_server 3.2.1 [async]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- image_cropper_for_web 3.0.0 [flutter flutter_web_plugins image_cropper_platform_interface js]
- image_cropper_platform_interface 5.0.0 [flutter plugin_platform_interface http]
- image_picker_android 0.8.7+5 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- image_picker_for_web 3.0.1 [flutter flutter_web_plugins image_picker_platform_interface mime]
- image_picker_ios 0.8.8+2 [flutter image_picker_platform_interface]
- image_picker_linux 0.2.1+1 [file_selector_linux file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_macos 0.2.1+1 [file_selector_macos file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_platform_interface 2.9.1 [cross_file flutter http plugin_platform_interface]
- image_picker_windows 0.2.1+1 [file_selector_platform_interface file_selector_windows flutter image_picker_platform_interface]
- io 1.0.4 [meta path string_scanner]
- js 0.6.7 [meta]
- logging 1.2.0
- matcher 0.12.16 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.5.0 [collection]
- mime 1.0.4
- nested 1.0.0 [flutter]
- node_preamble 2.0.2
- octo_image 1.0.2 [flutter flutter_blurhash]
- package_config 2.1.0 [path]
- path 1.8.3
- path_parsing 1.0.1 [vector_math meta]
- path_provider_android 2.2.0 [flutter path_provider_platform_interface]
- path_provider_foundation 2.3.1 [flutter path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.1 [flutter platform plugin_platform_interface]
- path_provider_windows 2.2.1 [ffi flutter path path_provider_platform_interface win32]
- permission_handler_android 10.3.6 [flutter permission_handler_platform_interface]
- permission_handler_apple 9.1.4 [flutter permission_handler_platform_interface]
- permission_handler_platform_interface 3.11.5 [flutter meta plugin_platform_interface]
- permission_handler_windows 0.1.3 [flutter permission_handler_platform_interface]
- petitparser 5.4.0 [meta]
- platform 3.1.0
- plugin_platform_interface 2.1.6 [meta]
- pointycastle 3.7.3 [collection convert js]
- pool 1.5.1 [async stack_trace]
- process 4.2.4 [file path platform]
- pub_semver 2.1.4 [collection meta]
- shared_preferences_android 2.2.1 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.3.4 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.3.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.3.1 [flutter plugin_platform_interface]
- shared_preferences_web 2.2.1 [flutter flutter_web_plugins shared_preferences_platform_interface]
- shared_preferences_windows 2.3.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- shelf 1.4.1 [async collection http_parser path stack_trace stream_channel]
- shelf_packages_handler 3.0.2 [path shelf shelf_static]
- shelf_static 1.1.2 [convert http_parser mime path shelf]
- shelf_web_socket 1.0.4 [shelf stream_channel web_socket_channel]
- sky_engine 0.0.99
- source_gen 1.4.0 [analyzer async build dart_style glob path source_span yaml]
- source_map_stack_trace 2.1.1 [path source_maps stack_trace]
- source_maps 0.10.12 [source_span]
- source_span 1.10.0 [collection path term_glyph]
- sprintf 7.0.0
- sqflite_common 2.5.0 [synchronized path meta]
- stack_trace 1.11.0 [path]
- stream_channel 2.1.1 [async]
- string_scanner 1.2.0 [source_span]
- sync_http 0.3.1
- synchronized 3.1.0
- term_glyph 1.2.1
- test_api 0.6.0 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- test_core 0.5.3 [analyzer async args boolean_selector collection coverage frontend_server_client glob io meta package_config path pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml test_api]
- timezone 0.9.2 [path]
- typed_data 1.3.2 [collection]
- uuid 4.0.0 [crypto sprintf]
- vector_graphics 1.1.7 [flutter vector_graphics_codec]
- vector_graphics_codec 1.1.7
- vector_graphics_compiler 1.1.7 [args meta path_parsing xml vector_graphics_codec]
- vector_math 2.1.4
- vm_service 11.7.1
- watcher 1.1.0 [async path]
- web 0.1.4-beta
- web_socket_channel 2.4.0 [async crypto stream_channel]
- webdriver 3.0.2 [matcher path stack_trace sync_http]
- webkit_inspection_protocol 1.2.1 [logging]
- webview_flutter_android 3.10.0 [flutter webview_flutter_platform_interface]
- webview_flutter_platform_interface 2.6.0 [flutter meta plugin_platform_interface]
- webview_flutter_wkwebview 3.7.4 [flutter path webview_flutter_platform_interface]
- win32 5.0.7 [ffi]
- yaml 3.1.2 [collection source_span string_scanner]
my app is working fine in IOS . but gives error for Android
2
Answers
I think you live in A country that is embargoed, and you need VPN to download some packages So try with VPN
The logs you provided indicate that your Application.kt file contains an "unresolved reference" error related to Firebase. This error can often be resolved by following the steps outlined in the Firebase documentation: https://firebase.flutter.dev/docs/messaging/overview/#3-android-integration
Specifically, if you are using Flutter Android Embedding V2 (Flutter Version >= 1.12), you typically don’t need any additional integration steps for Android. Maybe this error appeared after updating your Flutter version and now requires a clean application.kt.
Here’s what you can do to resolve the issue:
Check Application.kt: Take a closer look at your Application.kt file. Ensure that you have update it according to the docs.
Reference StackOverflow Post: Additionally, you can refer to this StackOverflow post for more detailed guidance:
Application.kt: Unresolved reference: firebasemessaging