Android Studio: How to build command-line Android

2019-09-08 17:46发布

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.

0条回答
登录 后发表回答