cannot get this adb shell am start line to work

3

I am trying to launch this app on my emulator.. Here is my adb shell am start line

C:\Users\harvey\AndroidStudioProjects\Sunshinea1>adb shell am start -n com.example.harvey.Sunshinea1app/com.example.harvey.Sunshinea1app.MainActivity
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
Starting: Intent { cmp=com.example.harvey.Sunshinea1app/.MainActivity }
Error type 3
Error: Activity class {com.example.harvey.Sunshinea1app/com.example.harvey.Sunshinea1app.MainActivity} does not exist.

C:\Users\harvey\AndroidStudioProjects\Sunshinea1>

I know the warning isn't such an issue but the MainActivity does not exist part of that message is pointing to an issue that is stopping the command from being able to start the program.

I know I have something wrong in regarding the path or the name but I can't see what. I guess i'm a bit confused by what is what. No doubt i've written the path wrong somewhere but I don't know where.

Here is a dir Sunshine* /s/b

I guess it might give some info that may help to determine what that adb line should be. If you need any other info please comment letting me know.

C:\Users\harvey\AndroidStudioProjects\Sunshinea1>dir Sunshine*.* /s/b
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\Sunshinea1.iml
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\build\generated\source\buildConfig\debug\com\example\harvey\sunshinea1app
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\build\generated\source\buildConfig\debug\com\example\harvey\sunshinea1app\sunshinea1
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\build\generated\source\buildConfig\test\debug\com\example\harvey\sunshinea1app
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\build\generated\source\buildConfig\test\debug\com\example\harvey\sunshinea1app\sunshinea1
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\build\generated\source\r\debug\com\example\harvey\sunshinea1app
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\build\generated\source\r\debug\com\example\harvey\sunshinea1app\sunshinea1
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\build\intermediates\classes\debug\com\example\harvey\sunshinea1app
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\build\intermediates\classes\debug\com\example\harvey\sunshinea1app\sunshinea1
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\src\androidTest\java\com\example\harvey\sunshinea1app
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\src\androidTest\java\com\example\harvey\sunshinea1app\sunshinea1
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\src\main\java\com\example\harvey\sunshinea1app
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\src\main\java\com\example\harvey\sunshinea1app\sunshinea1

C:\Users\harvey\AndroidStudioProjects\Sunshinea1>

EDIT was getting this error

C:\Users\harvey\AndroidStudioProjects\Sunshinea1>adb shell monkey -p com.example.harvey.Sunshinea1app -c android.intent.category.LAUNCHER 1
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
** No activities found to run, monkey aborted.

C:\Users\harvey\AndroidStudioProjects\Sunshinea1>

Looking at carlo's answer, i've decided to include my package name in the question, this from MainActivity.java

As for my package name

C:\>type C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\src\main\java\com\exampl
e\harvey\sunshinea1app\sunshinea1\MainActivity.java | grep package

package com.example.harvey.sunshinea1app.sunshinea1;

C:\>

So now i've revised the package line in the adb shell monkey line

C:\>adb shell monkey -p com.example.harvey.sunshinea1app.sunshinea1 -c android.intent.
category.LAUNCHER 1
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a secur
ity risk. Please fix.
Events injected: 1
## Network stats: elapsed time=85ms (0ms mobile, 0ms wifi, 85ms not connected)

the adb shell monkey line does work now..

C:\>adb devices
List of devices attached
emulator-5554   device


C:\>

But the adb shell am line isn't

C:\Users\harvey\AndroidStudioProjects\Sunshinea1>dir MainActivity.class /s/b
C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\build\intermediates\classes\debug\com\example\harvey\sunshinea1app\sunshinea1\MainActivity.class

C:\Users\harvey\AndroidStudioProjects\Sunshinea1>

attempts at adb shell am start

C:\Users\harvey\AndroidStudioProjects\Sunshinea1>adb shell am start -n com.example.harvey.sunshinea1app/com.example.harvey.sunshinea1app.MainActivity
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
Starting: Intent { cmp=com.example.harvey.sunshinea1app/.MainActivity }
Error type 3
Error: Activity class {com.example.harvey.sunshinea1app/com.example.harvey.sunshinea1a
pp.MainActivity} does not exist.

C:\Users\harvey\AndroidStudioProjects\Sunshinea1>adb shell am start -n com.example.harvey.sunshinea1app/com.example.harvey/.sunshinea1app/.MainActivity
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
Starting: Intent { cmp=com.example.harvey.sunshinea1app/com.example.harvey/.sunshinea1
app/.MainActivity }
Error type 3
Error: Activity class {com.example.harvey.sunshinea1app/com.example.harvey/.sunshinea1
app/.MainActivity} does not exist.

C:\Users\harvey\AndroidStudioProjects\Sunshinea1>

I checked this QnA

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

which had the idea of checking logcat then doing adb shell am and then -a(for what follows act=) -c(for what follows cat=) and -n(for what follows cmp=) based on the output..

02-09 18:04:05.763    1277-1288/? I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.harvey.sunshinea1app.sunshinea1/.MainActivity} from pid 1781

But it doesn't work

dir MainActivity.class /s/b shows MainActivity.class is stored here

C:\Users\harvey\AndroidStudioProjects\Sunshinea1\app\build\intermediates\classes\debug\com\example\harvey\sunshinea1app\sunshinea1\MainActivity.class

I run the adb shell am start command, with -a -c and -n, but it doesn't find the class

C:\>adb shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n com.example.harvey.sunshinea1app.sunshinea1/.MainActivity
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.harvey.sunshinea1app.sunshinea1/.MainActivity }
Error type 3
Error: Activity class {com.example.harvey.sunshinea1app.sunshinea1/com.example.harvey.
sunshinea1app.sunshinea1.MainActivity} does not exist.

C:\>

trying the suggestion in a comment

C:\>adb shell am start -n com.example.harvey.sunshinea1app/com.example.harvey/.sunshinea1app.MainActivity
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
Starting: Intent { cmp=com.example.harvey.sunshinea1app/com.example.harvey/.sunshinea1
app.MainActivity }
Error type 3
Error: Activity class {com.example.harvey.sunshinea1app/com.example.harvey/.sunshinea1app.MainActivity} does not exist.

C:\>

a better attempt as suggested in the comment, but still fails

C:\>adb shell am start -n com.example.harvey.sunshinea1app/.sunshinea1.MainActivity
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
Starting: Intent { cmp=com.example.harvey.sunshinea1app/.sunshinea1.MainActivity }
Error type 3
Error: Activity class {com.example.harvey.sunshinea1app/com.example.harvey.sunshinea1app.sunshinea1.MainActivity} does not exist.

C:\>

Here is a pic from devtools package manager for the sunshinea1 app that I am trying to do adb shell am start on.

enter image description here

android
adb
asked on Stack Overflow Feb 7, 2015 by barlop • edited May 23, 2017 by Community

2 Answers

5

You can launch the app using the following command which only needs the package name of the app:

adb shell monkey -p com.example.harvey.Sunshinea1app -c android.intent.category.LAUNCHER 1

As for why your command doesn't work, I can't tell from the information provided, but I suspect that the problem is where the MainActivity class is located in your package structure. If the MainActivity class is in com.example.harvey.sunshinea1app.sunshinea1 then you will need the following command:

adb shell am start -n com.example.harvey.sunshinea1app/.sunshinea1.MainActivity

Also ensure that the package name you are using is correct and in the correct letter casing.

Edit by barlop
Carlo points out in comment, and it works-

adb shell am start -n com.example.harvey.sunshinea1app.sunshinea1/.MainActivity

answered on Stack Overflow Feb 9, 2015 by Carlo B. • edited Feb 10, 2015 by Carlo B.
0

You may try doing as follows:

adb>adb shell
YOUR_DEVICE:> $ am start -n com.example.harvey.sunshinea1app.sunshinea1/.MainActivity
answered on Stack Overflow Dec 7, 2020 by jeet chheda

User contributions licensed under CC BY-SA 3.0