Skip to content
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
Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot.


Copy link

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.

Copy link

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!

Copy link

A PR is welcome to improve the process.

Copy link

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.

@grabbou grabbou added the Good first issue Interested in collaborating? Take a stab at fixing one of these issues. label Apr 20, 2016
Copy link

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(' ')})...`

Copy link

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.

Copy link

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.

Copy link

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

Copy link

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

Copy link

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

Copy link

southerneer commented Mar 9, 2017

New product pains link:

...and it seems like old links redirect correctly now.

Copy link

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

Copy link

ovy9086 commented Apr 7, 2018

yep. issue still occurs, and it is annoying.

Copy link

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
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot.
None yet

No branches or pull requests