Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port forwarding (adb reverse) stops working when startMethod is called #218

Open
Pacjonek opened this issue Dec 16, 2021 · 1 comment
Open
Labels

Comments

@Pacjonek
Copy link

Pacjonek commented Dec 16, 2021

Version:

1.5.0

Description:

Setting port forwarding (adb reverse) has no effect after run startActivity function.

I was able to get bypass the problem by removing the -W parameter from the ADB call which start activity:

async function startActivity(sdk, device, packageName, activityName) {
    const debug = Debug(`${modulePrefix}:${startActivity.name}`);
    const args = [
        '-s',
        device.serial,
        'shell',
        'am',
        'start',
        ~~'-W'~~,
        '-n',
        `${packageName}/${activityName}`,
    ];
    debug('Invoking adb with args: %O', args);
    await execAdb(sdk, args, { timeout: 5000 });
}

Command Output:

npx native-run android --connect --app app-debug.apk  --forward 8080:8080 --forward 8100:8100

 native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_HOME +0ms
  native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_SDK_ROOT +2ms
  native-run:android:utils:sdk:resolveSDKRoot Using $ANDROID_SDK_ROOT at C:\Users\prajba\AppData\Local\Android\Sdk\ +4ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking for $ANDROID_EMULATOR_HOME +0ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking at $HOME/.android +1ms
  native-run:android:utils:sdk:resolveEmulatorHome Using $HOME/.android/ at C:\Users\prajba\.android +1ms
  native-run:android:utils:sdk:resolveAVDHome Looking for $ANDROID_AVD_HOME +0ms
  native-run:android:utils:sdk:resolveAVDHome Looking at $HOME/.android/avd +1ms
  native-run:android:utils:sdk:resolveAVDHome Using $HOME/.android/avd/ at C:\Users\prajba\.android\avd +1ms
  native-run:android:utils:adb:getDevices Invoking adb with args: [ 'devices', '-l' ] +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\prajba\AppData\Local\Android\Sdk\platform-tools\package.xml +0ms
  native-run:android:utils:adb:parseAdbDevices Parsing adb devices from output lines: [
  native-run:android:utils:adb:parseAdbDevices   'List of devices attached',
  native-run:android:utils:adb:parseAdbDevices   '4b7948b7               device product:RMX2202EEA model:RMX2202 device:RMX2202L1 transport_id:1',
  native-run:android:utils:adb:parseAdbDevices   '',
  native-run:android:utils:adb:parseAdbDevices   ''
  native-run:android:utils:adb:parseAdbDevices ] +0ms
  native-run:android:utils:adb:getDeviceProperties Invoking adb with args: [ '-s', '4b7948b7', 'shell', 'getprop' ] +0ms
  native-run:android:utils:adb:getDevices Found adb devices: [
  native-run:android:utils:adb:getDevices   {
  native-run:android:utils:adb:getDevices     serial: '4b7948b7',
  native-run:android:utils:adb:getDevices     state: 'device',
  native-run:android:utils:adb:getDevices     type: 'hardware',
  native-run:android:utils:adb:getDevices     connection: null,
  native-run:android:utils:adb:getDevices     properties: {
  native-run:android:utils:adb:getDevices       product: 'RMX2202EEA',
  native-run:android:utils:adb:getDevices       model: 'RMX2202',
  native-run:android:utils:adb:getDevices       device: 'RMX2202L1',
  native-run:android:utils:adb:getDevices       transport_id: '1'
  native-run:android:utils:adb:getDevices     },
  native-run:android:utils:adb:getDevices     manufacturer: 'realme',
  native-run:android:utils:adb:getDevices     model: 'RMX2202',
  native-run:android:utils:adb:getDevices     product: 'RMX2202EEA',
  native-run:android:utils:adb:getDevices     sdkVersion: '30'
  native-run:android:utils:adb:getDevices   }
  native-run:android:utils:adb:getDevices ] +249ms
  native-run:android:utils:avd:getAVDINIs Discovered AVD ini files: [] +0ms
Selected hardware device 4b7948b7
  native-run:android:utils:adb:getDeviceProperty Invoking adb with args: [ '-s', '4b7948b7', 'shell', 'getprop', 'dev.bootcomplete' ] +0ms
  native-run:android:utils:adb:getDeviceProperty Invoking adb with args: [ '-s', '4b7948b7', 'shell', 'getprop', 'dev.bootcomplete' ] +0ms
  native-run:android:utils:adb:waitForBoot Device 4b7948b7 is booted! +0ms
  native-run:android:utils:adb:forwardPorts Invoking adb with args: [ '-s', '4b7948b7', 'reverse', 'tcp:8080', 'tcp:8080' ] +0ms       
  native-run:android:utils:adb:forwardPorts Invoking adb with args: [ '-s', '4b7948b7', 'reverse', 'tcp:8100', 'tcp:8100' ] +0ms       
  native-run:android:utils:adb:waitForBoot Device 4b7948b7 is booted! +53ms
Forwarded device port 8080 to host port 8080
Forwarded device port 8100 to host port 8100
Installing app-debug.apk...
  native-run:android:utils:adb:installApk Invoking adb with args: [
  native-run:android:utils:adb:installApk   '-s',
  native-run:android:utils:adb:installApk   '4b7948b7',
  native-run:android:utils:adb:installApk   'install',
  native-run:android:utils:adb:installApk   '-r',
  native-run:android:utils:adb:installApk   '-t',
  native-run:android:utils:adb:installApk   'app-debug.apk'  native-run:android:utils:adb:installApk ] +0ms
Starting application activity pl.x.y/pl.x.y.MainActivity...
  native-run:android:utils:adb:startActivity Invoking adb with args: [
  native-run:android:utils:adb:startActivity   '-s',
  native-run:android:utils:adb:startActivity   '4b7948b7',
  native-run:android:utils:adb:startActivity   'shell',
  native-run:android:utils:adb:startActivity   'am',
  native-run:android:utils:adb:startActivity   'start',
  native-run:android:utils:adb:startActivity   '-n',
  native-run:android:utils:adb:startActivity   'pl.x.y/pl.x.y.MainActivity'
  native-run:android:utils:adb:startActivity ] +0ms
Run Successful
Waiting for app to close...

SDK Info:

SDK Location: C:\Users\prajba\AppData\Local\Android\Sdk
AVD Home: C:\Users\prajba.android\avd

API Level: 31
Packages: Android SDK Platform 31 platforms;android-31 1
Sources for Android 31 sources;android-31 1
(!) Missing Packages: Google Play Intel x86 Atom System Image system-images;android-31;google_apis_playstore;x86 /.+/

API Level: 30
Packages: Android SDK Platform 30 platforms;android-30 3
(!) Missing Packages: Google Play Intel x86 Atom System Image system-images;android-30;google_apis_playstore;x86 /.+/

Tools:

Android Emulator emulator 30.9.5
Android SDK Build-Tools 30.0.2 build-tools;30.0.2 30.0.2
Android SDK Build-Tools 31 build-tools;31.0.0 31.0.0
Android SDK Platform-Tools platform-tools 31.0.3
Android SDK Tools tools 26.1.1
Intel x86 Emulator Accelerator (HAXM installer) extras;intel;Hardware_Accelerated_Execution_Manager 7.6.5
SDK Patch Applier v4 patcher;v4 1

@bastienlemaitre
Copy link

Up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants