无法让这个adb shell开始工作

时间:2015-02-07 23:03:45

标签: android adb

我正在尝试在我的模拟器上启动此应用..这是我的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>

我知道警告不是这样的问题,但MainActivity不存在该消息的一部分指向阻止命令启动程序的问题。

我知道我在路径或名称方面有问题,但我看不清楚是什么。我想我有点困惑的是什么。毫无疑问,我在某处写错了路径,但我不知道在哪里。

这是一个阳光* / s / b

我想它可能会提供一些信息,可能有助于确定adb行应该是什么。如果您需要任何其他信息,请发表评论告诉我。

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>

修改 得到了这个错误

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>

看看carlo的回答,我决定在问题中包含我的包名,这来自MainActivity.java

至于我的包裹名称

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:\>

所以现在我修改了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)

adb shell monkey line现在可以正常工作..

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


C:\>

但adb shell am line不是

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>

尝试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>

我查了这个QnA

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

有想法检查logcat 然后根据输出执行adb shell am然后-a(对于act =)-c(对于cat =)和-n(对于cmp =之后的内容)...

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

但它不起作用

dir MainActivity.class / s / b 显示MainActivity.class存储在这里

C:\用户\哈维\ AndroidStudioProjects \ Sunshinea1 \应用\构建\中间体\类\调试\ COM \示例\哈维\ sunshinea1app \ sunshinea1 \ MainActivity.class

我使用-a -c和-n运行adb shell am start命令,但是找不到类

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:\>

在评论中尝试建议

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:\>

评论中建议的更好的尝试,但仍然失败

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:\>

这是来自devtools软件包管理器的图片,我正在尝试使用ada shell开始使用sunshinea1应用程序。

enter image description here

2 个答案:

答案 0 :(得分:4)

您可以使用以下命令启动应用程序,该命令只需要应用程序的程序包名称:

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

至于为什么你的命令不起作用,我无法从提供的信息中说出来,但我怀疑问题是MainActivity类在你的包结构中的位置。如果MainActivity类在com.example.harvey.sunshinea1app.sunshinea1中,那么您将需要以下命令:

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

同时确保您使用的包名称正确并且使用正确的字母大小写。

barlop编辑
卡罗在评论中指出,它有效 -

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

答案 1 :(得分:0)

您可以尝试执行以下操作:

adb>adb shell
YOUR_DEVICE:> $ am start -n com.example.harvey.sunshinea1app.sunshinea1/.MainActivity