-
Notifications
You must be signed in to change notification settings - Fork 478
Add a command to build and run on Android #3239
Conversation
130debd
to
498bf88
Compare
.helpGroup('experimental') | ||
.description('Build a development client and run it in on a device.') | ||
.option('-p --platform <platform>', 'Platform: [android|ios]', /^(android|ios)$/i) | ||
.option('--build-variant [name]', '(Android) build variant', 'release') |
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.
hmm if this is a cross platform command, then we should probably attempt to make the arguments cross-platform too. If that's not feasible, then we should split ios and android build commands up.
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.
The intent was to match the convention used by eas build
, where the same command builds iOS and Android apps: eas build --platform ios
, eas build --platform android
or even eas build --platform all
.
It would be possible to do expo run:ios
and expo run:android
, but this (specifying the platform in the command name) is a pattern we've been trying to avoid in new code.
Cross-plaform arguments: Are you suggesting a new argument that maps to build variant name on Android and build configuration name on iOS?
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.
Renamed to run:android
for now. ¯\_(ツ)_/¯
return; | ||
} | ||
|
||
const spinner = ora('Building app ').start(); |
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.
build logs?
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.
Looks like this interferes with them, so I'm going to remove the spinner and use Log.log
instead.
|
||
const spinner = ora('Building app ').start(); | ||
|
||
const androidProjectPath = await AndroidConfig.Paths.getProjectPathOrThrowAsync(projectRoot); |
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.
Maybe add a check to use prebuild here?
const androidProjectPath = await AndroidConfig.Paths.getProjectPathOrThrowAsync(projectRoot).catch(() => null);
// If the project doesn't have native code, prebuild it...
if (!androidProjectPath) {
await prebuildAsync(projectRoot, {
install: true,
platforms: ['android'],
} as EjectAsyncOptions);
}
function getGradleTask(buildVariant: string): string { | ||
return `install${buildVariant.charAt(0).toUpperCase()}${buildVariant.slice(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.
Add more types and make it explicitly clear what's going on here. Also iirc, people often use the app:
prefix to target just the module? If there's reasoning to do/not do that, could you add it in a comment.
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.
Split this function, hopefully it's clearer now.
I'm not sure about app:
, I found this command in Android docs. If you know more, please let me know.
}); | ||
|
||
spinner.text = 'Starting the development client...'; | ||
await Android.openProjectAsync({ |
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.
wrap in a try/catch and fail the spinner
76052c3
to
fe22cf6
Compare
Why
This is going to be the v1 of the emulator flow for Android dev client. The command allows building, installing and launching the dev client app on Android.
How
Launch with
expod run --platform android
.TODO:
--help
Test Plan
npx crna -t with-development-client my-dev-client-app
cd my-dev-client-app
android/gradle.properties
:# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
expod run:android