디버그 모드에서 오류 또는 빨간색 화면이없는 경우에도 릴리스 모드의 Flutter Android 회색 화면
Nov 22 2020
Android 실제 장치에서 시작 화면 직후 시작시 회색 화면이 나타납니다. 모든 오류 또는 빨간색 화면을 해결했으며 다시 시도했지만 여전히 동일합니다.
참고 :이 앱을 플레이하기 전에이 앱의 2 가지 버전을 출시했습니다. 그래서 이것은 첫 번째가 아닙니다.
내 로그
Flutter run key commands.
h Repeat this help message.
c Clear the screen
q Quit (terminate the application on the device).
I/flutter (24661): <-- stops here nothing after this
답변
JohnJoe Nov 23 2020 at 05:57
때로는 디버그 모드에서는 잘 작동 하지만 릴리스 모드 에서는 작동 하지 않습니다 . 터미널에서 아래 명령을 실행하여 오류를 포착 할 수 있습니다.
flutter run --release
명령이 릴리스 모드로 컴파일됩니다. 회색 화면이 발생하면 디버그 콘솔을 확인할 수 있습니다.
Jagadish Nov 26 2020 at 07:14
UI에 오류가 없었기 때문에 아무것도 효과가 없었습니다. 오류는 메인 앱의 시작 부분에있었습니다. 추가 후 기적처럼 작동 await
하기 전에 Firebase.initializeApp();
.
void main() async {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.transparent));
**await** Firebase.initializeApp(); //adding await solved the problem
SharedPreferences.getInstance().then((prefs) {
var brightness = SchedulerBinding.instance.window.platformBrightness;
if (brightness == Brightness.dark) {
prefs.setBool('darkMode', true);
} else {}
var darkModeOn = prefs.getBool('darkMode') ?? false;
runApp(
ChangeNotifierProvider<ThemeNotifier>(
create: (_) => ThemeNotifier(darkModeOn ? darkTheme : lightTheme),
child: MaterialApp(
home: root(),
),
),
);
});
}