-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
.
@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 |
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: |
@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. |
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. |
Additionally, once we add flavors to build.gradle, the default |
Working nicely. Thank you! |
@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. |
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. |
why this is not merging? |
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? |
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. |
@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? |
First time I am aware of this. Can you please file a new issue? |
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. |
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 |
@nicodelpiano - I didn't use |
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... |
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. |
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 cli
that 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.gradle
file.default: debug
) into a buildType and a product flavorAndroidManifest.xml
that 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.