error "activity class does not exist" when launching android app with adb shell am start
Asked Answered
O

7

18

After adb install-ing my app, I can verify that it's there with adb shell pm list packages AppName:

package:air.com.client.AppName

So I know it's there, but when I try to launch it with adb shell am start -a android.intent.action.MAIN -n air.com.client/.AppName, I get this error:

Starting: Intent { cmp=air.com.client/.AppName}

Error type 3

Error: Activity class {air.com.client/air.com.client.AppName} does not exist.

If it matters, this is, as you may have noticed, an AIR app that's been packaged as an Android app. Any ideas? Did I miss something somewhere? When I use aapt dump xmltree I can see that my .apk includes an android.intent.action.MAIN entry in the intent-filter node, for what it's worth.

And finally, for sanity's sake, using the same command template I can launch the settings app with no problems:

adb shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings
Opec answered 26/11, 2013 at 23:39 Comment(3)
There is no air.com.client class. The class name is air.com.client.AppName.Ameeameer
you're gonna have to spell it out for me - what should the command be?Opec
related q #28389023Fugleman
O
11

Managed to figure it out - I left a prompt open with adb logcat, then launched my app on the device - out of this corresponding log entry:

I/ActivityManager( 2115): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=air.com.client.AppName/.AppEntry} from pid 2453

I put together a new command line:

adb shell start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n air.com.client.AppName/.AppEntry

... which does exactly what I wanted. I'll be honest, I don't understand exactly why it works, but that's good enough for now.

Opec answered 27/11, 2013 at 1:32 Comment(1)
I think you should add between 'shell' and 'start', am. Because you are using the activity managerFrick
K
25

Watch out for applicationIdSuffix!!

When using applicationIdSuffix in build.gradle the suffix only applies to your application id, not to the actual package structure in the generated .apk, meaning that referencing your activity the short way (.MainActivity, instead of using its fully qualified name) will add the application id suffix to the path of the activity too and hence AS will fail to locate it. E.g.:

My application's package name is my.application.package, and I have this in my app module's build.gradle:

buildTypes {
           
    someBuildType {
        [...]
        applicationIdSuffix ".dev"
    }
}

When trying to execute, let's say MainActivity (which is located in the root package) from the command line:

$ adb shell am start -n my.application.package.dev/.MainActivity

actually resolves to

$ adb shell am start -n my.application.package.dev/my.application.package.dev.MainActivity

But MainActivity is actually located in my.application.package.MainActivity, not in my.application.package.dev.MainActivity, because applicationIdSuffix changes only the application id, not the actual package structure, so it will fail to locate it.

Therefore, you should use the activity's fully qualified name:

$ adb shell am start -n my.application.package.dev/my.application.package.MainActivity
Katricekatrina answered 8/2, 2018 at 10:12 Comment(0)
O
11

Managed to figure it out - I left a prompt open with adb logcat, then launched my app on the device - out of this corresponding log entry:

I/ActivityManager( 2115): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=air.com.client.AppName/.AppEntry} from pid 2453

I put together a new command line:

adb shell start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n air.com.client.AppName/.AppEntry

... which does exactly what I wanted. I'll be honest, I don't understand exactly why it works, but that's good enough for now.

Opec answered 27/11, 2013 at 1:32 Comment(1)
I think you should add between 'shell' and 'start', am. Because you are using the activity managerFrick
H
4

At lease for me the issue was solved once I entered a full path to the main activity in the application manifest file.

Instead of:

<activity android:name=".MyMainActivity"/>

Use:

<activity android:name="com.fullPathToActivityPackage.MyMainActivity"/>

and then use the regular:

adb shell am start -n com.myAppPackage/com.fullPathToActivityPackage.MyMainActivity
Hacksaw answered 23/8, 2015 at 10:7 Comment(0)
U
1

The problem is for writing only the activity name without it's package

am start -a android.intent.action.MAIN -n air.com.client/.AppName

Is wrong,

First, You should enter the activity name (not the AppName), and second you can't enter the activity name without the package name .AppName alone wouldn't work. you should enter air.com.client.AppName even if the activity is in the exact same package as the application package.

This would probably work

am start -a android.intent.action.MAIN -n air.com.client.AppName/air.com.client.ActivityName
Unitarianism answered 24/1, 2015 at 15:33 Comment(0)
F
1

I created a new project by copying another existing, and got this problem. None of the answers above helped as all seemed to be correct. And what eventually resolved the issue in my case was just a restart of the Andriod Studio.

Fowkes answered 30/8, 2018 at 6:54 Comment(1)
Does not resolve my problem. Why is the package name duplicated in the shell command? This is the reason the activity can not be found.Sweyn
I
1

Check that in your field of Application in your device not has the apk with the same name. The new devices has paper bin and there is the problem.

Inadvisable answered 28/3, 2019 at 14:6 Comment(1)
Thanks, for me this helped. My uninstalled the app from my emulator and re-launched itAnnabal
D
0

For AIR application there is specific prefix and postifx. This works for me, application package is cz.jara

adb shell am start -n air.cz.jara/air.cz.jara.AppEntry

Note that sometimes there is .DEBUG appended to the package name.

Diathermy answered 20/12, 2019 at 15:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.