Skip to content

Multiple entry-points in same Dart file is broken #91841

@tvolkert

Description

@tvolkert

Bug report

Steps to reproduce

Create the following Dart program:

import 'package:flutter/widgets.dart';

@pragma('vm:entry-point')
void main() {
  runApp(ColoredBox(color: Color(0xffcc0000)));
}

@pragma('vm:entry-point')
void entryPoint() {
  runApp(ColoredBox(color: Color(0xff00cc00)));
}

... then override getDartEntrypointFunctionName in the Android MainActivity, like so:

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
  override fun getDartEntrypointFunctionName(): String {
    return "entryPoint"
  }
}

... then run the app on an Android device.

Expected behavior

You expect entryPoint() to be run as the program's entry-point, yielding a green screen.

Actual behavior

The app fails to start, with the following error:

E/flutter (16188): [ERROR:flutter/shell/common/shell.cc(103)] Dart Unhandled Exception: NoSuchMethodError: No top-level getter 'entryPoint' declared.
E/flutter (16188): Receiver: top-level
E/flutter (16188): Tried calling: entryPoint, stack trace: #0      NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:214:5)
E/flutter (16188): 
E/flutter (16188): [ERROR:flutter/runtime/dart_isolate.cc(727)] Could not resolve main entrypoint function.
E/flutter (16188): [ERROR:flutter/runtime/dart_isolate.cc(195)] Could not run the run main Dart entrypoint.
E/flutter (16188): [ERROR:flutter/runtime/runtime_controller.cc(415)] Could not create root isolate.
E/flutter (16188): [ERROR:flutter/shell/common/shell.cc(588)] Could not launch engine with configuration.

Notes

This scenario has been created in https://github.com/tvolkert/entrypoint

Culprit

This appears to have been introduced by #79669

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work lista: buildBuilding flutter applications with the toola: existing-appsIntegration with existing apps via the add-to-app flowc: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowfound in release: 2.3Found to occur in 2.3found in release: 2.8Found to occur in 2.8toolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions