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

[Android] react-native run-android: Parsing of AndroidManifest.xml wrong #5546

fkrauthan opened this Issue Jan 26, 2016 · 13 comments


None yet

fkrauthan commented Jan 26, 2016

I saw that for the command react-native run-android you guys are getting the package name of the application out of app/src/main/AndroidManifest.xml. This is ok if you change the application package in the gradle file AND in the AndroidManifest.xml.

A better way would be to look at the final generated AndroidManifest.xml in the build directory to find the actual application id to start up the application.


This comment has been minimized.

facebook-github-bot commented Jan 26, 2016

Hey fkrauthan, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

This comment has been minimized.


satya164 commented Jan 26, 2016

A PR is welcome to improve the process.


This comment has been minimized.

jayesbe commented Mar 6, 2016

I changed the Application ID and not the package name. the result is I can compile and launch the app for android via Android Studio.. but running from the command line results in

Error type 3
Error: Activity class {} does not exist.


This comment has been minimized.

ElvisChiang commented Jul 21, 2016

To respect applicationId in android/app/build.gradle then try to start activity by {applicationId}/{originalPackage}.MainActivity
Keeping MainActivity in original path is good for future migration.

--- a/local-cli/runAndroid/runAndroid.js
+++ b/local-cli/runAndroid/runAndroid.js
@@ -149,6 +149,11 @@ function run(args, reject) {

   try {
+    const applicationId = fs.readFileSync(
+      'app/build.gradle',
+      'utf8'
+    ).match(/applicationId "(.+?)"/)[1];
     const packageName = fs.readFileSync(
@@ -161,7 +166,7 @@ function run(args, reject) {
     if (devices && devices.length > 0) {
       devices.forEach((device) => {

-        const adbArgs = ['-s', device, 'shell', 'am', 'start', '-n', packageName + '/.MainActivity'];
+        const adbArgs = ['-s', device, 'shell', 'am', 'start', '-n', applicationId + '/' + packageName + '.MainActivity'];

           `Starting the app on ${device} (${adbPath} ${adbArgs.join(' ')})...`

This comment has been minimized.


kgritesh commented Jul 21, 2016

I have pushed a PR #8950 to solve this issue. I am using the advice given by @fkrauthan and am reading the package name from the final generated AndroidManifest.xml in the build directory. The real difficulty in the task is to figure out the path for the the generated manifest file as it depends upon the build type, product flavor as well the architecture that the build is run for.


This comment has been minimized.


mkonicek commented Oct 27, 2016

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home:

Product Pains has been very useful in highlighting the top bugs and feature requests:

Also, if this issue is a bug, please consider sending a pull request with a fix.

@mkonicek mkonicek added the Icebox label Oct 27, 2016

@mkonicek mkonicek closed this Oct 27, 2016


This comment has been minimized.

alexustinovsm commented Jan 11, 2017

Ammm... Isn't it in react-native cli?


This comment has been minimized.

fkrauthan commented Jan 12, 2017

No looks like this issue is still valid. I can't believe that no one accepted the PR that someone already made.


This comment has been minimized.

vongohren commented Feb 1, 2017

This thing is still alive? Im experiencing problems with this now, aswell are others:

Also the productpain page is not working anymore: "Oops! We couldn't find the page you were looking for."


This comment has been minimized.

southerneer commented Mar 9, 2017


This comment has been minimized.

Nandez89 commented Jan 19, 2018

Still having the same issue the app builds and installs but can't be opened on the emulator when running react-native run-android

Error type 3
Error: Activity class {packageName/packageName.MainActivity} does not exist.

I have a buildType for debug that adds the applicationIdSuffix '.dev' and I'm guessing this is why it can't find the activity to open but I'm not sure how to solve it. I definitely need the two build types


This comment has been minimized.

ovy9086 commented Apr 7, 2018

yep. issue still occurs, and it is annoying.


This comment has been minimized.


AndrewJack commented Apr 8, 2018

There are a ton of additional parameters you can pass in to resolve your issue.

For example:

react-native run-android --appIdSuffix dev --main-activity MainActivity --appFolder tvApp

See here:

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.