Uh oh!
There was an error while loading. Please reload this page.
Fixed the run-android cli script to start the correct activity when using different applicationId for different variants - #12820
Conversation
…sing different applicationId for different variants
vongohren
commented
Mar 10, 2017
Looks like someone else is doing the same: #12634 |
| function isSeparateBuildEnabled(gradleFilePath) { | ||
| // Check if separate build enabled for different processors | ||
| const content = fs.readFileSync(gradleFilePath, 'utf8'); | ||
| const separateBuild = content.match(/enableSeparateBuildPerCPUArchitecture\s+=\s+([\w]+)/)[1]; |
There was a problem hiding this comment.
I think there should be a null check for separateBuild before you access [1] of it. Reason: I was integrating React Native in an existing project and by default it did not have this key in the build.gradle file, nor is it necessary. So it would keep throwing the wrong error because the code for getManifestFile is wrapped in a try catch. So the error that an end user actually gets is adb invocation failed. Do you have adb in your PATH?.
karanjthakkar
commented
Mar 28, 2017
@Snorlock I find this more reliable because:
I have tried this PR while integrating an existing project of mine and it worked perfectly with the exception of #12820 (comment). @hramos@mkonicek Getting this in would really help solve issues faced by people who are integrating RN into existing apps which have different build types and product flavor configurations. What would it take to get this merged? I'd love to help! // cc: @satya164 |
Shane-Goodwin
commented
Apr 4, 2017
I came across this pull request while searching for a solution to this problem. The changes outlined worked almost perfectly except that line 288 should search for "buildTypes" plural. I changed it from: |
kgritesh
commented
Apr 8, 2017
@ericvicenti@karanjthakkar@Phredward since #13169 is already merged, i am assuming this PR is no longer necessary as it was trying to automatically get the appSuffixID. Please advise if I should close this or make it work with changes in the above mentioned issue. |
karanjthakkar
commented
Apr 8, 2017
Phredward
commented
Apr 8, 2017
Hi. I do still feel that it's worth trying to make runAndroid understand build.gradle so that developers only need to specify one argument to run their app (which variant to run). That said, I no longer think the above is urgent, and I'm happy to take another stab at making this happen with the newer code, depending on what people think is the right way forward. |
aranda-adapptor
commented
May 8, 2017
Additionally, once we add flavors to build.gradle, the default |
rod-stuchi
commented
Aug 3, 2017
Working nicely. Thank you! |
facebook-github-bot
commented
Aug 9, 2017
@kgritesh I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
steinnes
commented
Aug 9, 2017
This works for me as well, we're using custom |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
mnsrv
commented
Oct 13, 2017
why this is not merging? |
MrLoh
commented
Nov 4, 2017
It seems like #13169 wasn't merged and there's still no solution for this, since the first pull request was release in July 2016? |
hramos
commented
Nov 13, 2017
Whenever one of your flavors has a different package name #13169 still fails as it will use the packageName from the wrong AndroidManifest.xml. That is, it will not use the AndroidManifest.xml that was generated during build. This patch is still needed, your conclusion is wrong. |
Rovack
commented
Dec 21, 2017
@hramos, In light of the 11 people (at least) who believe the linked PR did not, in fact, solve the problem that necessitated this one, perhaps you could reconsider closing this? |
hramos
commented
Dec 21, 2017
First time I am aware of this. Can you please file a new issue? |
johanforssell
commented
Sep 19, 2018
I'm writing new versions of old apps, and thus I have inherited old app id's. My code have the package My First the app can be installed with gradlew The I can start it manually with This is a bloody hassle. I would rather not have to mess with it like this. |
famousfilm
commented
Oct 9, 2018
Cross-posting what @Lavielle wrote because it solved my problem. Quote:
When building and running dev ( Then I noticed, if I build the prod variant first and have it installed on the device, building and installing the dev variant works fine.
So this is not really an answer, but it worked for me and maybe it can help some of you guys out :) |
@famousfilm Are you sure that works? I'm guessing you are executing the Activity from |
famousfilm
commented
Nov 13, 2018
@nicodelpiano - I didn't use |
philjoseph
commented
Feb 18, 2019
I have different ProductFlavors with completely different App ID's and this PR is resolving the pb of the application launch. I really think this shall be merged @hramos |
This is affecting us as well, on 0.56. Thanks @kgritesh for the PR. Maintainers: let's please see this re-opened and merged... |
hramos
commented
Feb 19, 2019
The CLI is no longer part of the repository in 0.59. Please open a new issue / PR against https://github.com/react-native-community/react-native-cli instead. |
elirangoshen
commented
Oct 21, 2019
I still have this issue. on rn 0.60.4 please reopen this |
I have fixed the old PR #8950 for the latest version of react-native. This PR fixes the
runAndroid.js clithat uses the manifest file that is generated during the build process to find out the correct package name and activity name. As a result, it solves the issue where runAndroid command fails to start the app after installing it. Relevant Issue: #5546.Some feedback i received for the last PR is to see if the desired result can be achieved using less lines of code. I looked at it again and am not sure i know how to achieve that. I list the step involved in order to fix this issue below.
Find the correct manifest file for the particular variant that was installed
android/app/build.gradlefile.default: debug) into a buildType and a product flavorAndroidManifest.xmlthat is generated for the current run.Parse the manifest file found above and extract correct
activity class.Use this activity class to start the app after its installed
Let me know @hramos@sharnik@Snorlock@chuyik if this works or any pointers in how to fix this.