Skip to content

Flutter run fails when an activity-alias is used in the Android manifest #80532

Closed

Description

@PieterAelse

Explanation

When using an <activity-alias> in the AndroidManifest.xml the command futter run is unable to build the app (I guess because it cannot find the activity in the manifest).

<activity-alias> in the AndroidManifest.xml is for example typically used in the case of an app-update where the name of the launcher activity (e.g. MainActivity) has changed (e.g. NewMainActivity). It seems that flutter run cannot handle this and fails to build/run the app.

More info on the activity-alias tag in the AndroidManifest can be found here

Sample project:

See https://github.com/PieterAelse/flutter_android_activity_alias_issue .
And specifically this commit where the activity-alias changes are highlighted.

Steps to Reproduce

  1. Create a new flutter project using flutter create
  2. Try flutter run with an Android device attached/emulated, it will succeed.
  3. Add an <activity-alias> for the used Activity and remove the <intent-filter> used as launcher for the Activity itself (otherwise you'll see 2 launcher icons when installing the app).
  4. Try flutter run with an Android device attached/emulated, it will fail with the error:

package identifier or launch activity not found.
Please check
[redacted_path]/flutter_android_activity_alias_issue/android/app/src/main/AndroidManifest.xml for errors.
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.

screenshot

Logs

Logs
[redacted]:flutter_android_activity_alias_issue pieter$ flutter run
Launching lib/main.dart on sdk gphone x86 in debug mode...
package identifier or launch activity not found.
Please check
[redacted_path]/flutter_android_activity_alias_issue/android/app/src/main/AndroidManifest.xml for errors.
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.
Flutter doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.3, on macOS 11.2.3 20D91 darwin-x64, locale
    en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Community Edition (version 2021.1)
[✓] Connected device (3 available)

• No issues found!

Activity

  1. PieterAelse commented on Apr 15, 2021

    @PieterAelse
    Author

    The issue is "fixed" when some build data is already there, for example when running flutter build apk --debug and then flutter run.

    Example build and then run output
    MACC02XF4FFJGH5:flutter_android_activity_alias_issue pieter$ flutter build apk --debug
    Running Gradle task 'assembleDebug'...
    Running Gradle task 'assembleDebug'... Done                        33.2s
    ✓ Built build/app/outputs/flutter-apk/app-debug.apk.
    MACC02XF4FFJGH5:flutter_android_activity_alias_issue pieter$ flutter run
    Using hardware rendering with device sdk gphone x86. If you notice graphics
    artifacts, consider enabling software rendering with
    "--enable-software-rendering".
    Launching lib/main.dart on sdk gphone x86 in debug mode...
    Running Gradle task 'assembleDebug'...
    Running Gradle task 'assembleDebug'... Done                        15.6s
    ✓ Built build/app/outputs/flutter-apk/app-debug.apk.
    Installing build/app/outputs/flutter-apk/app.apk...                 1.0s
    Waiting for sdk gphone x86 to report its views...                    8ms
    Syncing files to device sdk gphone x86...                          366ms
    
    Flutter run key commands.
    r Hot reload. 🔥🔥🔥
    R Hot restart.
    h Repeat this help message.
    d Detach (terminate "flutter run" but leave application running).
    c Clear the screen
    q Quit (terminate the application on the device).
    An Observatory debugger and profiler on sdk gphone x86 is available at:
    http://127.0.0.1:60650/3epvlPSac4E=/
    

    But, after running flutter clean you will again run into the error when using flutter run..

  2. TahaTesser commented on Apr 16, 2021

    @TahaTesser
    Contributor

    Hi @PieterAelse
    activity-alias not yet supported
    I see there's an open issue addressing the case you described.
    Please follow up on that issue, Closing as duplicate of #38965
    If you disagree, please write in the comments and I will reopen it.
    Thank you

  3. added
    r: duplicateIssue is closed as a duplicate of an existing issue
    and removed
    in triagePresently being triaged by the triage team
    on Apr 16, 2021
  4. github-actions commented on Aug 3, 2021

    @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.

  5. locked as resolved and limited conversation to collaborators on Aug 3, 2021
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

    r: duplicateIssue is closed as a duplicate of an existing issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions