1

I have a simple android app .apk file create with Expo (react native) using the expo build:android script.

I am trying to run this on a device which is locked down by the provider so their is no access to Expo client. The only interface is via ADB.

I have successfully installed the app using the following command:

adb -s <device_id> install <package-name>.apk

I am then trying to start the app via the following:

adb shell am start -n host.exp.myapp

But I get the following error:

Exception: java.lang.IllegalArgumentException: Bad component name: host.exp.myapp

When I run adb shell cmd package list packages, I can see the package:host.exp.myapp listed and I am sure it's following naming conventions with lowercase and no special characters.

How can I start my app via ADB?

Stretch0
  • 8,362
  • 13
  • 71
  • 133
  • https://stackoverflow.com/questions/4567904/how-to-start-an-application-using-android-adb-tools – ADM May 26 '22 at 11:09

2 Answers2

1

Use the command

adb shell monkey -p com.package.name  -c android.intent.category.LAUNCHER 1
It starts the activity as if it was launched using the launcher. Replace com.package.name with desired package name in the command.
Mritunjay Gupta
  • 311
  • 2
  • 8
0

If you only know the package name and not the Activity you can use AndroidViewClient/culebra which resolves it.

For example, if you only knows the Chrome package name com.android.chrome you can run

#! /usr/bin/env python3

from com.dtmilano.android.viewclient import ViewClient


device, serialno = ViewClient.connectToDeviceOrExit()
device.startActivity(package='com.android.chrome')

and it is resolved to the main Activity and then started.

If you want to do it from adb without using python you can take a look at the source here.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134