Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception: type 'List<String>' is not a subtype of type 'ReactiveTodosRepository' of 'todosRepository' #28564

Closed
harshvardhan opened this issue Feb 27, 2019 · 6 comments

Comments

@harshvardhan
Copy link

harshvardhan commented Feb 27, 2019

After using the same configuration for several days, yesterday I run into this compilation failure.

Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
/Users/harshvardhan/Documents/work/portable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.1+3/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:9: error: cannot find symbol
import androidx.annotation.NonNull;
                          ^
  symbol:   class NonNull
  location: package androidx.annotation
/Users/harshvardhan/Documents/work/portable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.1+3/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:10: error: cannot find symbol
import androidx.annotation.Nullable;
                          ^
  symbol:   class Nullable
  location: package androidx.annotation
/Users/harshvardhan/Documents/work/portable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.1+3/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:706: error: cannot find symbol
  private void reportException(Result result, @Nullable Exception exception) {
                                               ^
  symbol:   class Nullable
  location: class FirebaseAuthPlugin
/Users/harshvardhan/Documents/work/portable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.1+3/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:610: error: cannot find symbol
    public void onComplete(@NonNull Task<AuthResult> task) {
                            ^
  symbol:   class NonNull
  location: class FirebaseAuthPlugin.SignInCompleteListener
/Users/harshvardhan/Documents/work/portable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.1+3/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:629: error: cannot find symbol
    public void onComplete(@NonNull Task<Void> task) {
                            ^
  symbol:   class NonNull
  location: class FirebaseAuthPlugin.TaskVoidCompleteListener
/Users/harshvardhan/Documents/work/portable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.1+3/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:647: error: cannot find symbol
    public void onComplete(@NonNull Task<SignInMethodQueryResult> task) {
                            ^
  symbol:   class NonNull
  location: class FirebaseAuthPlugin.GetSignInMethodsCompleteListener
/Users/harshvardhan/Documents/work/portable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.1+3/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:187: error: cannot find symbol
                      public void onComplete(@NonNull Task<AuthResult> task) {
                                              ^
  symbol: class NonNull
/Users/harshvardhan/Documents/work/portable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.1+3/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:492: error: cannot find symbol
              public void onComplete(@NonNull Task<GetTokenResult> task) {
                                      ^
  symbol: class NonNull
/Users/harshvardhan/Documents/work/portable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.1+3/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:559: error: cannot find symbol
          public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                                          ^
  symbol: class NonNull
9 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':firebase_auth:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for 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 FAILED in 24s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1

Steps to Reproduce

  1. Using this example from flutter_architecture_samples repo on Github to develop my app.
  2. Downgraded following plugins:
    #From:
  firebase_auth: 0.8.1+3
  cloud_firestore: 0.9.5+2
  firebase_messaging: 4.0.0+1
  shared_preferences: ^0.5.0

#To:

  firebase_auth: 0.7.0
  cloud_firestore: 0.8.2+3
  firebase_messaging: 2.1.0
  shared_preferences: 0.4.3
  1. Try to run the app.
  2. App build successfully but crashes with following crash.

As the error message suggested I downgraded the versions of flutter plugins. After I did that i am able to build the app successfully but the app crashes on the word go. Posting the error here:

E/flutter ( 9032): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type 'List<String>' is not a subtype of type 'ReactiveTodosRepository' of 'todosRepository'
E/flutter ( 9032): #0      _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:185:38)
E/flutter ( 9032): #1      _rootRun (dart:async/zone.dart:1124:13)
E/flutter ( 9032): #2      _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter ( 9032): #3      _runZoned (dart:async/zone.dart:1516:10)
E/flutter ( 9032): #4      runZoned (dart:async/zone.dart:1500:12)
E/flutter ( 9032): #5      _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:180:5)
E/flutter ( 9032): #6      _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:300:19)
E/flutter ( 9032): #7      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
E/flutter ( 9032): 

Logs

[  +54 ms] executing: [/Users/harshvardhan/Documents/work/portable/flutter/] git rev-parse --abbrev-ref
--symbolic @{u}
[  +75 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/beta
[        ] executing: [/Users/harshvardhan/Documents/work/portable/flutter/] git rev-parse --abbrev-ref
HEAD
[  +14 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] beta
[        ] executing: [/Users/harshvardhan/Documents/work/portable/flutter/] git ls-remote --get-url
origin
[  +18 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[        ] executing: [/Users/harshvardhan/Documents/work/portable/flutter/] git log -n 1
--pretty=format:%H
[  +33 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[        ] 8661d8aecd626f7f57ccbcb735553edc05a2e713
[        ] executing: [/Users/harshvardhan/Documents/work/portable/flutter/] git log -n 1
--pretty=format:%ar
[  +16 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[   +1 ms] 12 days ago
[   +2 ms] executing: [/Users/harshvardhan/Documents/work/portable/flutter/] git describe --match v*.*.*
--first-parent --long --tags
[  +43 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.2.1-0-g8661d8aec
[ +727 ms] executing: /Users/harshvardhan/Library/Android/sdk/platform-tools/adb devices -l
[  +43 ms] Exit code 0 from: /Users/harshvardhan/Library/Android/sdk/platform-tools/adb devices -l
[        ] List of devices attached
           fe6f9295               device usb:336592896X product:OnePlus5 model:ONEPLUS_A5000
           device:OnePlus5 transport_id:7
           emulator-5554          device product:sdk_gphone_x86 model:Android_SDK_built_for_x86
           device:generic_x86 transport_id:6
[  +48 ms] executing: idevice_id -h
[  +83 ms] /usr/bin/xcrun simctl list --json devices
[ +370 ms] More than one device connected; please specify a device with the '-d <deviceId>' flag, or use
'-d all' to
                    act on all devices.
[   +6 ms] /Users/harshvardhan/Library/Android/sdk/platform-tools/adb -s fe6f9295 shell getprop
[  +90 ms] ro.hardware = qcom
[   +4 ms] /Users/harshvardhan/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell getprop
[  +29 ms] ro.hardware = ranchu
[   +5 ms] ONEPLUS A5000             • fe6f9295      • android-arm64 • Android 9 (API 28)
[   +1 ms] Android SDK built for x86 • emulator-5554 • android-x86   • Android 8.1.0 (API 27) (emulator)
[  +28 ms] "flutter run" took 1,343ms.
[        ] "flutter run" took 1,343ms.

#0      throwToolExit (package:flutter_tools/src/base/common.dart:24:3)
#1      RunCommand.validateCommand (package:flutter_tools/src/commands/run.dart:240:7)
<asynchronous suspension>
#2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:525:11)
<asynchronous suspension>
#3      FlutterCommand.run.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command.dart:482:33)
<asynchronous suspension>
#4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142:29)
<asynchronous suspension>
#5      _rootRun (dart:async/zone.dart:1124:13)
#6      _CustomZone.run (dart:async/zone.dart:1021:19)
#7      _runZoned (dart:async/zone.dart:1516:10)
#8      runZoned (dart:async/zone.dart:1463:12)
#9      AppContext.run (package:flutter_tools/src/base/context.dart:141:18)
<asynchronous suspension>
#10     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:473:20)
#11     CommandRunner.runCommand (package:args/command_runner.dart:196:27)
<asynchronous suspension>
#12     FlutterCommandRunner.runCommand.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command_runner.dart:396:21)
<asynchronous suspension>
#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142:29)
<asynchronous suspension>
#14     _rootRun (dart:async/zone.dart:1124:13)
#15     _CustomZone.run (dart:async/zone.dart:1021:19)
#16     _runZoned (dart:async/zone.dart:1516:10)
#17     runZoned (dart:async/zone.dart:1463:12)
#18     AppContext.run (package:flutter_tools/src/base/context.dart:141:18)
<asynchronous suspension>
#19     FlutterCommandRunner.runCommand
(package:flutter_tools/src/runner/flutter_command_runner.dart:356:19)
<asynchronous suspension>
#20     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:111:29)
#21     new Future.sync (dart:async/future.dart:224:31)
#22     CommandRunner.run (package:args/command_runner.dart:111:11)
#23     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:242:18)
#24     run.<anonymous closure> (package:flutter_tools/runner.dart:60:20)
<asynchronous suspension>
#25     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142:29)
<asynchronous suspension>
#26     _rootRun (dart:async/zone.dart:1124:13)
#27     _CustomZone.run (dart:async/zone.dart:1021:19)
#28     _runZoned (dart:async/zone.dart:1516:10)
#29     runZoned (dart:async/zone.dart:1463:12)
#30     AppContext.run (package:flutter_tools/src/base/context.dart:141:18)
<asynchronous suspension>
#31     runInContext (package:flutter_tools/src/context_runner.dart:48:24)
<asynchronous suspension>
#32     run (package:flutter_tools/runner.dart:51:10)
#33     main (package:flutter_tools/executable.dart:52:9)
<asynchronous suspension>
#34     main
(file:///Users/harshvardhan/Documents/work/portable/flutter/packages/flutter_tools/bin/flutter_tools.dart:
8:3)
#35     _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:298:32)
#36     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

flutter doctor output

[✓] Flutter (Channel beta, v1.2.1, on Mac OS X 10.13.6 17G65, locale en-SG)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.3)
[✓] Connected device (1 available)

• No issues found!

main.dart

void main([
  ReactiveTodosRepository todosRepository,
  ReactiveFeedsRepository feedsRepository,
  ReactiveUserFeedsRepository userFeedsRepository,
  ReactiveAuditRepository auditRepository,
  UserFirebaseRepository userRepository,
  SCUserRepositoryImpl scUserRepository
]) async {

  FlutterError.onError = (FlutterErrorDetails details) {
    if (isInDebugMode) {
      // In development mode simply print to console.
      FlutterError.dumpErrorToConsole(details);
    } else {
      // In production mode report to the application zone to report to
      // Crashlytics.
      Zone.current.handleUncaughtError(details.exception, details.stack);
    }
  };

  await FlutterCrashlytics().initialize();

  runZoned<Future<Null>>(() async {
    runApp(ReduxApp(
      todosRepository: todosRepository,
      feedsRepository: feedsRepository,
      userFeedsRepository: userFeedsRepository,
      auditRepository: auditRepository,
      userRepository: userRepository,
      scUserRepository: scUserRepository,
    ));
  }, onError: (error, stackTrace) async {
    // Whenever an error occurs, call the `reportCrash` function. This will send
    // Dart errors to our dev console or Crashlytics depending on the environment.
    await FlutterCrashlytics().reportCrash(error, stackTrace, forceCrash: false);
  });
}

class ReduxApp extends StatelessWidget {
  final Store<AppState> store;
  ReduxApp({
    Key key,
    ReactiveTodosRepository todosRepository,
    ReactiveFeedsRepository feedsRepository,
    ReactiveUserFeedsRepository userFeedsRepository,
    ReactiveAuditRepository auditRepository,
    UserFirebaseRepository userRepository,
    SCUserRepositoryImpl scUserRepository,
  })  : store = Store<AppState>(
          appReducer,
          initialState: AppState.initial(),
          middleware: createStoreTodosMiddleware(
            todosRepository ??
                FirestoreReactiveTodosRepository(Firestore.instance),
            feedsRepository ??
                FirestoreReactiveFeedsRepository(Firestore.instance),
            userFeedsRepository ??
                FirestoreReactiveUserFeedsRepository(Firestore.instance),
            auditRepository ?? AuditAPIRepository(),
            userRepository ?? FirebaseUserRepository(FirebaseAuth.instance),
            scUserRepository ?? SCUserRepositoryImpl(),
          ),
        ),
        super(key: key) {
    store.dispatch(InitAppAction());
  }

  @override
  Widget build(BuildContext context) {
    return StoreProvider(
      store: store,
      child: MaterialApp(
        debugShowCheckedModeBanner: false,
        title: FirestoreReduxLocalizations().appTitle,
        theme: ArchSampleTheme.theme,
        localizationsDelegates: [
          ArchSampleLocalizationsDelegate(),
          FirestoreReduxLocalizationsDelegate(),
        ],
        routes: {
          ArchSampleRoutes.signin: (context) => SignIn(),
          ArchSampleRoutes.home: (context) => HomeScreen(),
        },
      ),
    );
  }
}
@zoechi
Copy link
Contributor

zoechi commented Feb 27, 2019

See https://goo.gl/CP92wY for more information

You need to migrate to AndroidX

Please consider asking support questions in one of the other channels listed at http://flutter.io/support .

@harshvardhan
Copy link
Author

harshvardhan commented Feb 27, 2019

Hey @zoechi, I followed that page and choose the option to avoid migrating to AndroidX. It didn't work.

Then I tried to go by the books and migrated the android module to androidx and opening it in separate android window and choosing the refactoring > Migrate to AndroidX option. BUt still not getting to fix this.

I have posted a question https://stackoverflow.com/questions/54910211/errorflutter-lib-ui-ui-dart-state-cc148-unhandled-exception

I think my issue is somewhat similar to #27346.

Please let me know if you have any pointers!

@SGuzel
Copy link

SGuzel commented Mar 5, 2019

Hey folks, is there any fixes for the "Unhandled Exception: type 'List' is not a subtype of type" Problem?

@dark-chocolate
Copy link

@SGuzel Please consider asking these questions on other communities like Stackoverflow.

@gching
Copy link

gching commented Mar 23, 2019

@harshvardhan and for whoever finds this issue, this is not an AndroidX issue, but void main() is only passed one parameter which is of type List<String> (usually, this is considered the args that is passed in the command line).

It wasn't always like this, but I am assuming a newer version of dart or flutter made it so it passes in this List<String> parameter whenever flutter runs your target file. Personally, I do not have time to test this assumption so if anyone can that would be helpful. But for now, just know that void main() is passed in only one parameter which is of type List<String>.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants