You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR from late '23 added the ability for the "main" activity to be programatically pulled from the manifest using the intent declarations, rather then assuming it would be called mainActivity and requiring the user to override it with a param if they used something else.
In my project however the main acitivity pull attempt ends up as blank, this results in run-android failing with the following:
Error type 3, Error: Activity class {com.example.dev/com.example.myapp} does not exist.
Again note that it does not have .mainActivity, or any activity, at all, as one would expect
Running config in my project also ends up with an empty mainActivity entry in the android project info, see Enironment
I have tracked this down for my project to the fact that for various reasons i have activities declared in the manifest that have intent nodes that do not have action/category nodes within them, for example
When the getMainActivity function added in that PR attempts to process my manifest and the above activity in particular it 'extracts' null for the category entry of the intent (Line 55), puts that into an array (Line 66) and then attempts to read props of that (Line 77 i believe), this exception is caught and null is returned resulting in the situations above.
As far as i can tell from documentation its perfectly legitimate to have intents without actions or categories, indeed my app with those intents has been in production for years with no issue, and the getMainActivity code is already, tehcnically, null checking action and category as it can disclude any activities without both as they will never be the "main" activity.
However the null checking doesnt occur until after the "is this an array, if not make it one" step (line 60 and 66) , which in the case of missing action/category nodes puts null into an array, this array is not null-ish thus the null check lets it through.
I can confirm for my project adding a null check on action and category to line 56 allows the function to move past these activities and properly process my manifest and correctly find my MainActivity,
i unfortunately do not have the capicity to see a PR for this fix through thouroghly so thought best i raise this as an issue.
Reproducible Demo
Create a React-Native App with and android activity declaration that has intents but does not have either an action or category node as per my example above.
The text was updated successfully, but these errors were encountered:
hey @cameroncharles! thank you for such nicely described issue, it helped me a lot with understanding your issue! I've submitted #2432 which I hope will solve your issue. Let me know if you're able to test it 🙌
@szymonrybczak i was able to test this just now, by patching in the fix, and can confirm it does the trick for my project it correctly pulls the main activity with this fix in place, also added it to another project of mine that was otherwise running fine and there were no side effects to speak off so looks good to me
Environment
Relevant part of
react-native config
(name/path of app changed throughout as it doesnt really matter)
"android": {
"sourceDir": "C:.......\android",
"appName": "app",
"packageName": "com.example.myapp",
"applicationId": "com.example.myapp",
"mainActivity": "",
"unstable_reactLegacyComponentNames": []
}
Note the empty "mainActivity"
Description
This PR from late '23 added the ability for the "main" activity to be programatically pulled from the manifest using the intent declarations, rather then assuming it would be called mainActivity and requiring the user to override it with a param if they used something else.
In my project however the main acitivity pull attempt ends up as blank, this results in run-android failing with the following:
Again note that it does not have .mainActivity, or any activity, at all, as one would expect
Running
config
in my project also ends up with an empty mainActivity entry in the android project info, see EnironmentI have tracked this down for my project to the fact that for various reasons i have activities declared in the manifest that have intent nodes that do not have action/category nodes within them, for example
When the getMainActivity function added in that PR attempts to process my manifest and the above activity in particular it 'extracts' null for the category entry of the intent (Line 55), puts that into an array (Line 66) and then attempts to read props of that (Line 77 i believe), this exception is caught and null is returned resulting in the situations above.
As far as i can tell from documentation its perfectly legitimate to have intents without actions or categories, indeed my app with those intents has been in production for years with no issue, and the getMainActivity code is already, tehcnically, null checking action and category as it can disclude any activities without both as they will never be the "main" activity.
However the null checking doesnt occur until after the "is this an array, if not make it one" step (line 60 and 66) , which in the case of missing action/category nodes puts null into an array, this array is not null-ish thus the null check lets it through.
I can confirm for my project adding a null check on action and category to line 56 allows the function to move past these activities and properly process my manifest and correctly find my MainActivity,
i unfortunately do not have the capicity to see a PR for this fix through thouroghly so thought best i raise this as an issue.
Reproducible Demo
Create a React-Native App with and android activity declaration that has intents but does not have either an action or category node as per my example above.
The text was updated successfully, but these errors were encountered: