how to find the flutter crash reason in android studio - flutter

When I start debug my flutter(2.0.1) app in Android studio 4.2, the app start and crashed. there has no error log output, what should I do to find why the app crashed? this is the startup log(no error message):
This will generate a JSON format file containing all messages that
need to be translated.
Launching lib/main.dart on iPhone 11 Pro in debug mode...
Running Xcode build...
Xcode build done. 16.8s
I run the run command:
/Users/dolphin/source/cruise-open/.dart_tool/flutter_build/b649952ecb0be9dfc3fd2e301c2ba3d8/kernel_snapshot.d package:Cruise/main.dart
[+1901 ms] ../../.pub-cache/hosted/pub.flutter-io.cn/video_player_platform_interface-2.2.0/lib/messages.dart:4:1: Error: A library can't opt out of null
safety by
default, when using sound null safety.
[ +1 ms] // #dart = 2.8
[ ] ^^^^^^^^^^^^^^
[ +35 ms] ../../.pub-cache/hosted/pub.flutter-io.cn/wakelock_platform_interface-0.1.0+1/lib/messages.dart:4:1: Error: A library can't opt out of null
safety by
default, when using sound null safety.
[ ] // #dart = 2.8
[ ] ^^^^^^^^^^^^^^
[ +71 ms] Error: Cannot run with sound null safety, because the following dependencies
[ ] don't support null safety:
[ ] - package:shared_preferences
[ ] - package:timeago
[ ] - package:hive
[ ] - package:hive_flutter
but I already add null safety config:

Please run the app using the command
flutter run -v
This will give you complete verbose logging.

Related

Flutter run waiting for connection from debug service on chrome

I use flutter on window 10, when i run flutter on console and perform flutter run -d chrome, the error is waiting for connection from debug service on chrome. The error from chrome page show "The connection cant be reach".
My flutter doctor show i didnt install Visual Studio, but i already used to the Visual Studio Code. Is it a must to install Visual Studio ? Other than that, everything is passed.
I try to run the app on Visual Studio Code, the error is the same. Even on edge, on web-server. The error is the same.
I try to add Dart Debug Extension on Chrome but cannot be enable. Can some help ?
My flutter run -d chrome --verbose show below :
[tag:C:\Users\Administrator\myflutter_app>flutter run -d chrome --verbose
[ +10 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[+19685 ms] Waiting for connection from debug service on Chrome... (completed in 20.0s)
[ +2 ms] Synced 30.6MB.
[ +1 ms] <- accept
[ ] Caching compiled dill
[+2477 ms] [CHROME]:
[ +18 ms] [CHROME]: DevTools listening on ws://127.0.0.1:57469/devtools/browser/51db6ac9-54b7-4fb7-bdb4- 25fb1707d9d6]
The problem can be solved by performing the following actions
Upgraded flutter to latest version
Reinstall android studio
run flutter pub upgrade --major-versions
upgrade your chrome to latest
if you are using any extension in VS code to run flutter then there is also a possibility that the extension is not working properly try to change the version.
If it works give me a upvote,I'm new here.

Flutter: Error compiling biometric_storage ^4.1.3 for Linux

I am using biometric_storage ^4.1.3 for my flutter app and it compiles for Android and Windows.
Before installing biometric_storage it compiled for Linux as well, but now it throws a clang error due to undefined reference to g_task_set_name (a glib function) in libsecret.
[ +12 ms] //lib/x86_64-linux-gnu/libsecret-1.so.0: undefined reference to 'g_task_set_name'
[ +12 ms] //lib/x86_64-linux-gnu/libsecret-1.so.0: undefined reference to 'g_task_get_name'
[ ] clang: error: linker command failed with exit code 1 (use -v to see invocation)
[ +4 ms] ninja: build stopped: subcommand failed.
Edit 1:
I am able to use flutter_locker package for now. It only supports mobile platforms.

Flutter app crashes before integration tests start (chrome)

I am having an issue in experimenting with flutter integration tests. My goal is to be able to run headless tests for training purposes (a student produces an app, that I will test automatically). As it runs on servers it has to be headless and as quick as possible, so I chose chromedriver (I am not sure this is the best choice though, if you have other ideas please feel free to tell me).
I followed the tutorial here: https://flutter.dev/docs/cookbook/testing/integration/introduction
I created an empty project, filled lib/main.dart, test_driver/app.dart, test_driver/app_test.dart and pubspec.yaml exactly as suggested on the link above.
Then I tried to run this command:
flutter drive --target=test_driver/app.dart
Everything works properly, all tests passed
Then I launched chromedriver with chromedriver --port=4444 and tried to launch the test on chrome as suggested in the tutorial:
flutter drive test_driver/app.dart --browser-name=chrome --release
In this situation, after some time chrome opens and immediately crash ("Application finished"), juste before app_test.dart is launched:
Running "flutter pub get" in test_simple... 657ms
Launching test_driver/app.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome... 17,1s
This app is linked to the debug service: ws://127.0.0.1:33437/_FLIixzh_w0=/ws
Debug service listening on ws://127.0.0.1:33437/_FLIixzh_w0=/ws
💪 Running with sound null safety 💪
Application finished.
00:00 +0: Counter App (setUpAll)
Then the tests hang here forever until I kill it manually. Adding the "-v" flag does not give more information on why the application itself has finished:
[ +23 ms] Running "flutter pub get" in test_simple... (completed in 828ms)
[ +172 ms] Generating /home/bolgar/StudioProjects/test_simple/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[ +90 ms] Launching test_driver/app.dart on Chrome in debug mode...
[ +125 ms] Updating assets
[ +99 ms] Waiting for connection from debug service on Chrome...
[ +102 ms] <- reset
[ +5 ms] /home/bolgar/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev /home/bolgar/snap/flutter/common/flutter/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot
--sdk-root /home/bolgar/snap/flutter/common/flutter/bin/cache/flutter_web_sdk/ --incremental --target=dartdevc --debugger-module-names --experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=true
--output-dill /tmp/flutter_tools.KSIJUI/flutter_tool.EKPQRL/app.dill --libraries-spec file:///home/bolgar/snap/flutter/common/flutter/bin/cache/flutter_web_sdk/libraries.json --packages
/home/bolgar/StudioProjects/test_simple/.dart_tool/package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-root
/home/bolgar/StudioProjects/test_simple/test_driver --filesystem-root /home/bolgar/StudioProjects/test_simple/test --filesystem-root /tmp/flutter_tools.KSIJUI/flutter_tools.XZNNYT --filesystem-scheme
org-dartlang-app --initialize-from-dill build/b1b715402d823b7fd5c2b68d2edcb2ce.cache.dill.track.dill --platform
file:///home/bolgar/snap/flutter/common/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk_sound.dill --sound-null-safety
[ +8 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[+15724 ms] Waiting for connection from debug service on Chrome... (completed in 15,8s)
[ ] Synced 30.4MB.
[ ] <- accept
[ ] Caching compiled dill
[ +73 ms] Using Google Chrome 93.0.4577.63
[ +491 ms] [CHROME]:
[ ] [CHROME]:DevTools listening on ws://127.0.0.1:45213/devtools/browser/359be11c-4ac2-4ec0-b7ff-4fb67b69bf85
[ +169 ms] DwdsInjector: Received request for entrypoint at http://localhost:36257/main_module.bootstrap.js
[ +4 ms] MetadataProvider: Loading debug metadata...
[ +11 ms] MetadataProvider: Loaded debug metadata (sound null safety)
[ +5 ms] DwdsInjector: Injected debugging metadata for entrypoint at http://localhost:36257/main_module.bootstrap.js
[+1576 ms] ChromeProxyService: Initializing expression compiler for main_module.bootstrap.js with sound null safety: true
[ +47 ms] DevHandler: Debug service listening on ws://127.0.0.1:39027/zQL0xCzGkSU=/ws
[ +15 ms] This app is linked to the debug service: ws://127.0.0.1:39027/zQL0xCzGkSU=/ws
[ +4 ms] Debug service listening on ws://127.0.0.1:39027/zQL0xCzGkSU=/ws
[ ] 💪 Running with sound null safety 💪
[ +522 ms] Application finished.
[ +27 ms] DevHandler: Stopped debug service on ws://127.0.0.1:38021
[ +355 ms] executing: /home/bolgar/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/dart /home/bolgar/StudioProjects/test_simple/test_driver/app_test.dart -rexpanded
[+1584 ms] 00:00 +0: Counter App (setUpAll)
[ +180 ms] DwdsInjector: Received request for entrypoint at http://localhost:36257/main_module.bootstrap.js
[ ] MetadataProvider: Loading debug metadata...
[ +6 ms] MetadataProvider: Loaded debug metadata (sound null safety)
[ +2 ms] DwdsInjector: Injected debugging metadata for entrypoint at http://localhost:36257/main_module.bootstrap.js
[+104632 ms] DwdsInjector: Received request for entrypoint at http://localhost:36257/main_module.bootstrap.js
[ ] MetadataProvider: Loading debug metadata...
[ +6 ms] MetadataProvider: Loaded debug metadata (sound null safety)
[ +2 ms] DwdsInjector: Injected debugging metadata for entrypoint at http://localhost:36257/main_module.bootstrap.js
Can anyone help me here on how to debug this situation ? I must admit that I am stuck.
Thanks a lot,
PS: I would also like to output the results of the drive test in JSON format, as you do with flutter test --machine ..., but I can't find a way to do it with flutter drive ..., so if anyone has a clue please tell me, otherwise I will open another post.

Flutter app crashes on hot restart only on iOS Simulator

Not sure what is going on, but when I hot restart my flutter app crashes using iOS simulator. Hot restart works fine on an Android simulator. I even tried to uninstall and install XCode again.
Here is what gets printed on the terminal
[ +459 ms] Hot restart performed in 924ms.
[ +3 ms] Restarted application in 936ms.
[ +900 ms] Service protocol connection closed.
[ ] Lost connection to device.
[ +3 ms] DevFS: Deleting filesystem on the device (file:///Users/frederickmfinanga/Library/Developer/CoreSimulator/Devices/775342AF-E52F-46EB-9CDB-9C29720FC357/data/Containers/Data/Application/D093EF45-D895-481C-B965-CA56F7881A5C/tmp/the_hair_routinenSBAWo/the_hair_routine/)
Failed to send request: {"jsonrpc":"2.0","id":"46","method":"getMemoryUsage","params":{"isolateId":"isolates/4165970133496907"}}
[ +257 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not completed
[ +1 ms] "flutter run" took 646,839ms.
[ +259 ms] ensureAnalyticsSent: 242ms
[ +1 ms] Running shutdown hooks
[ ] Shutdown hook priority 4
[ ] Shutdown hooks complete
[ ] exiting with code 0
I had the same issue. After two days of debugging I have just found out it was caused by one of my dependencies. It is firebase_auth package version 1.1.3.
As I can see the issue is resolved in firebase_auth 1.1.4 released on 10th of May 2021.
So just update to firebase_auth 1.1.4 if you use this package
I faced something similar a few days back.
There can be two possibilities why it is happening :
You have not granted permission for something you are trying to access (like getting the location/camera ). If this is the case then read the docs of the package you might be using and add the permissions programatically.
Sometimes our podfile reference gets corrupted. (This is what happened in my case). For this delete your podfile.lock file (ios/podfile.lock). For a fresh start you can also delete your pubspec.lock as well. And then do a flutter pub get or simply run your app.

Flutter: Cloud_firestore will break your Android build if it or its dependencies aren't compatible with AndroidX

I can not use these both flutter plugins together:
cloud_firestore: ^0.9.0+2
barcode_scan: ^0.0.8
When run, error occured:
D8: Program type already present: android.arch.core.util.Function
*********************************************************
WARNING: This version of cloud_firestore will break your Android build if it or its dependencies aren't compatible with AndroidX.
See https: //goo.gl /CP92wY for more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
FAILURE: Build failed with an exception.
it compiled and runned on Android phone when I remove one of them. But both can not go together. How to fix?
In short
Add multidex library to android app dependency (/android/app/build.gradle)
...
android {
...
defaultConfig {
...
multiDexEnabled true
}
...
}
...
dependencies {
implementation 'com.android.support:multidex:1.0.3' // use latest version
...
}
...
under android directory
gradel.properties file
Add
android.useAndroidX=true
android.enableJetifier=true
Found the solution (for me, at least) !
I had the following issue:
[+1498 ms] > Task :app:crashlyticsUploadDeobsRelease
[ ] > Task :cloud_firestore:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :firebase_analytics:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :firebase_auth:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :firebase_core:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :firebase_crashlytics:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :firebase_dynamic_links:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :firebase_messaging:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :firebase_ml_vision:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :firebase_remote_config:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :flutter_local_notifications:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :google_sign_in:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :image_picker:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :share:prepareLintJarForPublish UP-TO-DATE
[ ] > Task :shared_preferences:prepareLintJarForPublish UP-TO-DATE
[+15399 ms] > Task :app:lintVitalRelease FAILED
[ ] *********************************************************
[ ] WARNING: This version of cloud_firestore will break your Android build if it or its dependencies aren't compatible with AndroidX.
[ ]
[ ] This warning prints for all Android build failures. The real root cause of the error may be unrelated.
[ ] *********************************************************
[ ] 317 actionable tasks: 273 executed, 44 up-to-date
[ +372 ms] Running Gradle task 'assembleRelease'... (completed in 75.7s)
[ ] *******************************************************************************************
[ ] The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
[ ]
It seems that runner version 1.2.1 was the responsible for this !
After I changed to version 1.2.0 it worked.
So, I changed the following line from android/app/build.gradle
androidTestImplementation 'androidx.test:runner:1.2.1'
to
androidTestImplementation 'androidx.test:runner: 1.2.0'
(Note: Also, don't forget to add in Firebase Console all SHA certificate fingerprints you are going to use in your apps.)
Report an issue with barcode_scan to have it updated for AndroidX.
Limit the plugin to a version that does not depend on AndroidX until a new barcode_scan version becomes available:
cloud_firestore: ^0.8.2
Or update barcode_scan manually like mentioned in
https://github.com/flutter/flutter/issues/28207#issuecomment-465600796