Commit a19e5e5
authored
fix: use namespace instead of appId when generating MainActivity (#1830)
Changes how the fully specified MainActivity is specified.
Previously, for `.`-prefixed activities, we read the `applicationId`
from `build.gradle` and appended the Activity name, e.g. `build.gradle`
with:
```
// ...
namespace "com.example"
defaultConfig {
applicationId "com.example.mobile"
// etc...
```
and `AndroidManifest.xml` with:
```
<activity android:name=".MainActivity" ... />
```
would generate `com.example.mobile.MainActivity`.
However, Android uses the application package's `namespace` instead of
AppID when creating the Activity name
([docs](https://developer.android.com/guide/topics/manifest/activity-element)):
> if the first character of the name is a period, such as
".ExtracurricularActivity", it is appended to the
[namespace](https://developer.android.com/studio/build/configure-app-module#set-namespace)
specified in the build.gradle file.
This means, in the previous example, the actual name of the main
activity would have been `com.example.MainActivity`.
This hasn't historically been a problem because the activity name is
only used when launching expo-dev-client apps, and Expo CNG generates an
Android application package with the same `namespace` and
`applicationId`, but we've run into a case of an application which
bypasses Expo CNG and overrides the default `applicationId` for legacy
reasons.
This PR changes the approach to correctly use the namespace in this
case.
The implementation is based on `@expo/config-plugin`'s implementation of
`getApplicationIdAsync`, which is not very resilient (it's just a regex
looking for `namespace` in the `build.gradle` file), but since it's only
used in projects using expo dev client at the moment, it should be good
enough (without having to properly parse Groovy files).
### How Has This Been Tested:
- check that apps using expo-dev-client still launch
### How Has This Change Been Documented:
INTERNAL1 parent d503776 commit a19e5e5
1 file changed
+23
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
84 | 96 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
90 | 100 | | |
91 | 101 | | |
92 | 102 | | |
93 | 103 | | |
94 | 104 | | |
95 | 105 | | |
96 | | - | |
| 106 | + | |
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
| |||
111 | 121 | | |
112 | 122 | | |
113 | 123 | | |
114 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
115 | 127 | | |
116 | | - | |
117 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
118 | 132 | | |
119 | 133 | | |
120 | 134 | | |
| |||
0 commit comments