Background: I've spent dozens of hours trying to get a simple app, with a form, to run properly.
It worked perfectly on someone else's machine last week and worked one time on mine, but never again. I've upgraded, sync'd, cleaned, etc so many times in an effort to fix whatever's not working that I can't retrace all of them.
I even started fresh via Create a New Flutter Project > Flutter Application, then added one screen with the form, and a few dependencies on pubspec.yaml
I'm not asking others to do my work, but I'm at the end of my rope and hoping to learn how to save myself:
What are the steps, resources & best practices to troubleshoot Flutter App in Android Studio?
Setup (not sure what's relevant):
2019 iMac on Mojave 10.14.6 (still using CS5 Illustrator - don't want to pay for CC subscription)
Android Studio 4.1.1
result of flutter doctor -v:
flutter doctor -v
[?] Flutter (Channel stable, 1.22.5, on Mac OS X 10.14.6 18G7016 darwin-x64, locale en-US)
? Flutter version 1.22.5 at /Users/mgav/Developer/flutter
? Framework revision 7891006299 (4 weeks ago), 2020-12-10 11:54:40 -0800
? Engine revision ae90085a84
? Dart version 2.10.4
[?] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
? Android SDK at /Users/mgav/Library/Android/sdk
? Platform android-30, build-tools 30.0.3
? 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-6915495)
? All Android licenses accepted.
[?] Xcode - develop for iOS and macOS (Xcode 11.3.1)
? Xcode at /Applications/Xcode.app/Contents/Developer
? Xcode 11.3.1, Build version 11C505
? CocoaPods version 1.10.0
[?] Android Studio (version 4.1)
? Android Studio at /Applications/Android Studio.app/Contents
? Flutter plugin installed
? Dart plugin version 201.9317
? Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[?] Connected device (1 available)
? Android SDK built for x86 (mobile) ? emulator-5554 ? android-x86 ? Android 10 (API 29) (emulator)
? No issues found!
rvm -v
rvm 1.29.11
ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin18]
Dart Analysis results: "Nothing to show" (no errors)
Analyze > Inspect Code (scope: whole project):
I've spent dozens of hours on StackOverflow and elsewhere trying to understand and fix these above, to no avail. Info is often old and contradictory, sometimes saying "that's not important." I've implemented solutions that don't fix the problem, then undone them, so I don't get even more tangled.
Here's a sample from Logcat (again, I've implemented solutions that don't fix the problem, then undone them, so I don't get even more tangled):
2021-01-09 14:54:03.572 1804-1996/? W/SurfaceFlinger: Faking VSYNC due to driver stall
2021-01-09 14:54:03.579 1824-1824/? W/wificond: Scan already started
2021-01-09 14:54:03.579 1824-1824/? E/wificond: NL80211_CMD_TRIGGER_SCAN failed: Device or resource busy
2021-01-09 14:54:03.579 2075-2253/? E/WificondScannerImpl: Failed to start scan, freqs=null
2021-01-09 14:54:04.583 1804-1996/? W/SurfaceFlinger: Faking VSYNC due to driver stall
2021-01-09 14:54:04.887 1790-2447/? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
2021-01-09 14:54:04.887 1790-2447/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2021-01-09 14:54:05.894 1804-1996/? W/SurfaceFlinger: Faking VSYNC due to driver stall
2021-01-09 14:54:06.901 1804-1996/? I/chatty: uid=1000(system) app identical 1 line
2021-01-09 14:54:07.909 1804-1996/? W/SurfaceFlinger: Faking VSYNC due to driver stall
2021-01-09 14:54:08.021 1790-2447/? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
2021-01-09 14:54:08.021 1790-2447/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2021-01-09 14:54:08.931 1824-1824/? W/wificond: Scan already started
2021-01-09 14:54:08.931 1824-1824/? E/wificond: NL80211_CMD_TRIGGER_SCAN failed: Device or resource busy
2021-01-09 14:54:08.931 2075-2253/? E/WificondScannerImpl: Failed to start scan, freqs=null
2021-01-09 14:54:09.934 1804-1996/? W/SurfaceFlinger: Faking VSYNC due to driver stall
pubspec.yaml
name: brand_new_flutter_app
description: A new Flutter application.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0
# BEGIN added by mgav
provider: ^4.3.2
rflutter_alert: ^1.1.0
#firebase_core: ^0.5.1
#cloud_firestore: ^0.14.4
#firebase_auth: ^0.18.2
#flutter_rating_bar: ^3.2.0+1
# carousel_slider: ^2.3.1
# flutter_form_builder: ^3.14.1
intl: ^0.16.1
flutter_form_builder: ^4.0.2
#flutter_form_builder: '4.0.2'
material_tag_editor: ^0.0.6
# mgav added "flutter_typeahead: "<=1.9.1"" below b/c "Error: Expected 0 type arguments. final TextFieldConfiguration<T> textFieldConfiguration;" temp solution per https://github.com/danvick/flutter_form_builder/issues/674
flutter_typeahead: "<=1.9.1"
# END added by mgav
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
main.dart:
import 'package:flutter/material.dart';
import 'clean-write-review.dart';
void main() {
WidgetsFlutterBinding
.ensureInitialized(); // added by mgav, per https://stackoverflow.com/questions/57689492/flutter-unhandled-exception-servicesbinding-defaultbinarymessenger-was-accesse
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Home Screen',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: WelcomeScreen(title: 'Home Page'),
routes: {
'/welcome': (context) => WelcomeScreen(),
'/cleanwritereview': (context) => CleanWriteReviewScreen(),
},
);
}
}
class WelcomeScreen extends StatefulWidget {
WelcomeScreen({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_WelcomeScreenState createState() => _WelcomeScreenState();
}
class _WelcomeScreenState extends State<WelcomeScreen> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.