Skip to content

Conversation

@jwajgelt
Copy link
Contributor

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):

if the first character of the name is a period, such as ".ExtracurricularActivity", it is appended to the 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:

INTERNAL

@vercel
Copy link

vercel bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
radon-ide Ready Ready Preview, Comment Jan 7, 2026 9:16am

@jwajgelt jwajgelt self-assigned this Dec 19, 2025
@jwajgelt jwajgelt requested a review from filip131311 December 19, 2025 14:40
Copy link
Collaborator

@filip131311 filip131311 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline


// The namespace field in build.gradle defines the Java package name for the app's code.
const matchResult = gradleBuild.contents.match(/namespace\s+['"].*['"]/);
return matchResult?.[1] ?? null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't it always return null? there is no capture group (()) defined in the regex so you will match but you want get the name space name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right.
It must've worked for me due to falling back to some other fallback handing it.

Copy link
Collaborator

@filip131311 filip131311 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 🇮🇹

@jwajgelt jwajgelt merged commit a19e5e5 into main Jan 7, 2026
9 checks passed
@jwajgelt jwajgelt deleted the @jwajgelt/fix_main_activity_detection branch January 7, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants