Skip to content

Using activity-alias as MAIN/LAUNCHER activity will throw an incorrect error when using flutter run #38965

Closed

Description

@petermnt

When using an activity-alias in the AndroidManifest.xml for your main activity it is not picked up by the Flutter tools and will thrown an error even though it's a valid state. (see https://developer.android.com/guide/topics/manifest/activity-alias-element )
The application will run correctly when using ./gradlew installDebug, confirming that it's a valid state.
Only the detection in https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/application_package.dart#L209 is incorrect.

Steps to Reproduce

  1. run flutter create activity_alias
  2. remove the intent-filter from the .MainActivity
  3. add an activity-alias
        <activity-alias android:name="this.doesnt.matter" android:targetActivity=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity-alias>
  1. run flutter run

Logs

[  +36 ms] package identifier or launch activity not found.
[   +1 ms] Please check /Users/peter/dev/github/activity_alias/android/app/src/main/AndroidManifest.xml for errors.
[   +3 ms] No application found for TargetPlatform.android_x86.
           Is your project missing an android/app/src/main/AndroidManifest.xml?
           Consider running "flutter create ." to create one.

#0      throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:475:7)
<asynchronous suspension>
#2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:478:18)
<asynchronous suspension>
#3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:383:33)
<asynchronous suspension>
#4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153: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:152:18)
<asynchronous suspension>
#10     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:375:20)
#11     CommandRunner.runCommand (package:args/command_runner.dart:197: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:153: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:152: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:112:25)
#21     new Future.sync (dart:async/future.dart:224:31)
#22     CommandRunner.run (package:args/command_runner.dart:112:14)
#23     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:242:18)
#24     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:22)
<asynchronous suspension>
#25     _rootRun (dart:async/zone.dart:1124:13)
#26     _CustomZone.run (dart:async/zone.dart:1021:19)
#27     _runZoned (dart:async/zone.dart:1516:10)
#28     runZoned (dart:async/zone.dart:1500:12)
#29     run.<anonymous closure> (package:flutter_tools/runner.dart:60:18)
<asynchronous suspension>
#30     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#31     _rootRun (dart:async/zone.dart:1124:13)
#32     _CustomZone.run (dart:async/zone.dart:1021:19)
#33     _runZoned (dart:async/zone.dart:1516:10)
#34     runZoned (dart:async/zone.dart:1463:12)
#35     AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#36     runInContext (package:flutter_tools/src/context_runner.dart:56:24)
<asynchronous suspension>
#37     run (package:flutter_tools/runner.dart:51:10)
#38     main (package:flutter_tools/executable.dart:62:9)
<asynchronous suspension>
#39     main (file:///Users/peter/dev/sdk/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#40     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#41     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
Analyzing activity_alias...                                             
No issues found! (ran in 1.1s)

[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.6 18G87, locale en-BE)
    • Flutter version 1.7.8+hotfix.4 at /Users/peter/dev/sdk/flutter
    • Framework revision 20e59316b8 (5 weeks ago), 2019-07-18 20:04:33 -0700
    • Engine revision fee001c93f
    • Dart version 2.4.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
    • Android SDK at /Users/peter/dev/sdk/Android
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.1
    • ANDROID_HOME = /Users/peter/dev/sdk/Android
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.7.5

[✓] iOS tools - develop for iOS devices
    • ios-deploy 1.9.4

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 37.1.1
    • Dart plugin version 191.8405
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 38.2.4
    • Dart plugin version 192.6459

[✓] VS Code (version 1.37.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.3.0

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!

Activity

  1. added
    t: gradle"flutter build" and "flutter run" on Android
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Sep 4, 2019
  2. changed the title [-]Using activity-alias as MAIN/LAUNCHER activity will throw an incorrect error when using flutter run[/-] [+]Using activity-alias as MAIN/LAUNCHER activity will throw an incorrect error when using `flutter run`[/+] on Jan 10, 2020
  3. added
    P3Issues that are less important to the Flutter project
    on Aug 18, 2020
  4. muarachmann commented on Dec 18, 2020

    @muarachmann

    Same issue here...

  5. PieterAelse commented on Apr 16, 2021

    @PieterAelse

    @TahaTesser Could you add the customer:solaris to this ticket? As the duplicate (#80532 ) is seen there.

    And is there any good workaround for this?

  6. petermnt commented on Apr 16, 2021

    @petermnt
    Author

    @PieterAelse You can work around this issue by recreating an activity on your old location.

    <activity android:name="your.old.package.YourOldActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

    Which then launches the actual flutter activity

    class YourOldActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            startActivity(Intent(this, FlutterActivity::class.java))
            finish()
        }
    }
  7. danielalonsomendez commented on Dec 16, 2021

    @danielalonsomendez

    Any update?

  8. armandojimenez commented on Apr 1, 2022

    @armandojimenez

    any updates on this? 3 years old issue....

  9. neokree commented on Jun 9, 2022

    @neokree

    Any updates? Is there a way for us to fix this bug on flutter?

  10. armandojimenez commented on Jul 2, 2022

    @armandojimenez

    Anyone found a way to deal with this?

  11. yanshouwang commented on Jul 20, 2022

    @yanshouwang

    Is there any solution with this issue? it's useful for multi-flavors with different intent-filters

  12. 15 remaining items

  13. vishnukvmd commented on Mar 12, 2025

    @vishnukvmd

    A workaround is to add <category android:name="android.intent.category.LAUNCHER"/> to main/AndroidManifest.xml, and to remove that particular node from your build flavor(s) (eg. flavor/AndroidManifest.xml):

    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER" tools:node="remove"/>
    </intent-filter>
  14. added
    team-androidOwned by Android platform team
    and removed
    team-toolOwned by Flutter Tool team
    triaged-toolTriaged by Flutter Tool team
    P3Issues that are less important to the Flutter project
    on Jun 30, 2025
  15. added
    P3Issues that are less important to the Flutter project
    triaged-androidTriaged by Android platform team
    on Jul 1, 2025
  16. chaudharydeepanshu commented on Jan 23, 2026

    @chaudharydeepanshu

    Hi @SNNafi thanks for the PR but I see that it is closed. If you’re not planning to take it on, would it be okay for someone else to pick it up?

  17. SNNafi commented on Jan 24, 2026

    @SNNafi

    Thanks. Please do @chaudharydeepanshu

  18. ssaranyainfotech commented on Sep 11, 2026

    @ssaranyainfotech

    A workaround is to add <category android:name="android.intent.category.LAUNCHER"/> to main/AndroidManifest.xml, and to remove that particular node from your build flavor(s) (eg. flavor/AndroidManifest.xml):

    Saved my day

  19. added a commit that references this issue on Sep 12, 2026
    05f1a0b
  20. added a commit that references this issue on Sep 14, 2026
    27e6507
  21. github-actions commented on Sep 26, 2026

    @github-actions

    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.

  22. locked as resolved and limited conversation to collaborators on Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilitycustomer: solarist: gradle"flutter build" and "flutter run" on Androidteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions