Skip to content

Commit

Permalink
refactor: update logs in add android
Browse files Browse the repository at this point in the history
  • Loading branch information
rams23 committed Mar 2, 2023
1 parent e62b142 commit 299fed7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Windows android support work in progress

| Feature | Android | iOS |
|------------------------------------| :---: | :---: |
| Run on emulator | 🚧 ||
| Run on emulator | ||
| Run on device | 🚧| 🚧 |
| Debug build | 🚧 | 🚧 |
| Build flavor/variants | 🚧 | 🚧 |
| Build flavor/schema | | |
| Release build | 🚧 | 🚧 |
| Sign application | 🚧 | 🚧 |
| Incremental build | 🚧| 🚧 |
Expand Down
1 change: 0 additions & 1 deletion src/application/androidUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {getAppName, getRootDestinationFolder} from './utils'

export function getAppBuildFolder(buildType?: string) {
console.log('getAppBuildFolder', buildType);
// todo add debug
const appPath = `${getRootDestinationFolder()}/android/${buildType ? `${buildType}/` : ''}debug`
return appPath
Expand Down
9 changes: 6 additions & 3 deletions src/application/runAndroid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import tryLaunchEmulator from '@react-native-community/cli-platform-android/buil
import {buildAndroid} from './buildAndroid'
import {getAppBuildFolder} from './androidUtils'
import path from 'path'
import logger from './logger'

function getAdbPath() {
const androidHome = process.env.ANDROID_HOME
Expand Down Expand Up @@ -105,9 +106,13 @@ function getBundleIdentifier(appBuildFolder: string): string {
export async function runApp(buildType?: string, port = '8081') {

if (!checkBuildPresent(buildType)) {
buildAndroid(buildType)
logger.info('Build not present, starting build');
await buildAndroid(buildType)
}else {
logger.info('Build already present, skipping build');
}

// todo improvement: if there is only one device, use it directly
const device = await listAndroidDevices()

const appIdentifier = getBundleIdentifier(getAppBuildFolder(buildType))
Expand All @@ -124,10 +129,8 @@ export async function runApp(buildType?: string, port = '8081') {
} else {
const newEmulatorPort = await getAvailableDevicePort()
const emulator = `emulator-${newEmulatorPort}`
console.info('Launching emulator...')
const result = await tryLaunchEmulator(getAdbPath(), device.readableName, newEmulatorPort)
if (result.success) {
console.info('Successfully launched emulator.')
tryRunAdbReverse(port, emulator)

installApp(emulator, getProjectRootDir(), buildType)
Expand Down

0 comments on commit 299fed7

Please sign in to comment.