Skip to content

run-android with custom package build variants launch wrong MainActivity #12480

@dkpalmer

Description

@dkpalmer

--- Please use this template, and delete everything above this line before submitting your issue ---

Description

I've setup three different build types: release, beta, and debug. beta and debug have different package names from release, e.g.:

release: com.myapp
beta: com.myapp.beta
debug: com.myapp.debug

When running react-native run-android --variant=beta, build and install work as expected (gradle commands use the proper variant). However, launching the app results in the Android CLI trying to launch Starting: Intent { cmp=com.myapp/.MainActivity } against the default app package. I was expecting the CLI to try and launch cmp=com.myapp.beta/com.myapp.MainActivity.

When I don't have any of these builds installed prior it just errors on launch ("MainActivity does not exist") and I can easily go in and manually launch the app. However, if I have my release build pre-installed, my release build ends up getting launched when trying to run both beta and debug variants, which can be confusing.

Reproduction

CLI Issue

Solution

The runAndroid.js script pulls the packageName from the src AndroidManifest.xml file. With different build types/variants/flavors, the app package may be different and should be pulled from app/build/intermediates/manifests. Then the command to launch should be similar to adb shell am start -n com.myapp.beta/com.myapp.MainActivity.

I have this working locally, but haven't tested it extensively with the different ways of running Android builds. I'm happy to put up a PR with what I have if anyone wants to collab on this.

Additional Information

  • React Native version: 0.42.0rc3
  • Platform: Android
  • Operating System: MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions