Terminal run dalvikvm with am.jar

試著忘記壹切 提交于 2019-12-23 01:03:14

问题


I'm trying to start an installed app with dalvikvm in terminal. It doesn't work if I try to do this just so:

dalvikvm -cp /system/app/Calculator.apk com.android.calculator2/.Calculator

Then comes failure message : dalvikvm cannot find a main class

So I tried to run an "am start" in dalvikvm:

dalvikvm -cp system/framework/am.jar com.android.commands.am.Am 

It really works. But if I trying then to start an app:

dalvikvm -cp system/framework/am.jar com.android.commands.am.Am start -n com.android.calculator2/.Calculator

it doesn't work.

Can somebody help me please?


回答1:


A couple of points:

  1. You cannot run an android application from the terminal. In your first command, it would execute a static void main(String[]) method in the Calculator class, if there were one. It's not possible to "execute" an application in this manner.

  2. Using am is the correct way to start a specific activity from the terminal. You can simply use the provided "am" script (/system/bin/am). Or at least look at that script to see how to correctly invoke am.

For example, am start -n com.android.calculator2/.Calculator should do what you want




回答2:


You can run dalvikvm headless with vogar. You'll have to build it from SVN; the prebuilt jar is out of date!



来源:https://stackoverflow.com/questions/8873537/terminal-run-dalvikvm-with-am-jar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!