问题
I need to build a command-line tool that I can run in an Android shell.
This question is not about how to build using command-line tools, which is pretty much all I find when I search SO/google for this question.
What I can do: Write a simple Java jar that runs from app_process
What I want: A tool that uses Android libraries (such as the packagemanager) that runs from the command line (such as an 'adb shell') and then exits - so not an App, doesn't have a view and isn't really following the Android life-cycle.
So presumably I either need to figure out how to build such a tool either from an IDE (such as Android Studio) or else from the command-line using the Android libraries.
Someone gave the (mostly) reasonably suggestion that I just look at how 'pm' is compiled, though I can't figure out how to do that without downloading the entire Android source and doing a full build (and I don't really have the time or HD space for that).
So I suppose another solution would be if someone could just telling me how to compile 'pm' since I could repurpose that for my needs.
来源:https://stackoverflow.com/questions/30946516/android-studio-how-to-build-command-line-android-activity-with-no-view-not-how