-
Notifications
You must be signed in to change notification settings - Fork 25k
Fix activity path in run-android launch command with multiple build variants #12634
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
Conversation
- Eg `react-native run-android --variant DemoDebug --applicationId com.android.dem.debug`
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact [email protected] if you have any questions. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
…-android - Get the path to BuildConfig.java from variant and parse the APPLICATION_ID - Remove applicationId option
|
Ok, so I change the PR a bit. We don't really need the applicationId option as we can get it from the variant. I use the productFlavor and buildType in the variant option to get the path to BuildConfig.java. From there I parse the We can also define and run a gradle task to generate applicationId, but it is not so nice. I have to change the code quite a bit as it has to run after BuildConfig.java is generated (via build apk task) |
| const productFlavor = variantKeys[0], buildType = variantKeys[1]; | ||
| const packagePath = packageName.replace('.', '/'); | ||
| const applicationId = fs.readFileSync( | ||
| `app/build/generated/source/buildConfig/${productFlavor}/${buildType}/${packagePath}/BuildConfig.java`, |
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.
productFlavor is not a compulsory field so it may or may not exist. In cases where it doesn't the path to the BuildConfig.java file will be malformed. Eg: (app/build/generated/source/buildConfig//debug/com/example/BuildConfig.java)
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.
Also, if I dont have any flavors, then there is no right way to differentiate between whether the value in the variant flag is a flavor or a build type. I think a better way would be to add another flag or follow the implementation in #12820
|
@khacanh 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. |
|
Hi @khacanh, |
|
i am in the same situation @SuhairZain |
|
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. |
|
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. |
I use the productFlavor and buildType in the variant option to get the path to BuildConfig.java. From there I parse the APPLICATION_ID for that build variant.
We can also define and run a gradle task to generate applicationId, but it is not so nice.
I have to change the code quite a bit as it has to run after BuildConfig.java is generated (via build apk task)
Test plan (required)
react-native run-android --variant DemoDebug