英文:
how do i run cmd command on android programmatically with java code
问题
我是新手,对于Java和Android Studio的开发并不熟悉。我正在开发一个需要在应用程序内部运行“gradlew assembleDebug”命令的应用程序。这是否可能?
英文:
I am new to java and Andriod studio development. I working on an app that need to run "gradlew assembleDebug" command in the app itself.
is that possible?
答案1
得分: 1
Android不会在其内部附带任何构建工具。在您的手机上,没有gradle。
理论上,您可以制作一个包含这些工具的应用,但这非常复杂;对于刚接触Java和Android开发的人来说,这听起来像是一个非常不明智的项目。
--
或者,您是指:您正在为Android Studio编写插件,并且它需要运行gradlew?那听起来不是一个好主意:Android Studio本身会围绕调用gradle执行许多操作,并且可能已经内置了它;您应该告诉Studio去调用它,而不是自己执行。我不知道该如何做到这一点,不过。
--
如果您真的想要调用命令,请使用ProcessBuilder。但正如我所说,这不是您在这里想要做的。
英文:
Android does not ship with any build tools inside it. On your phone, there is no gradle.
In theory you can make an app that ships these tools but this is very complicated; that sounds like a project far beyond sensible for someone new to java and android development.
--
Or, did you mean: You are writing a plugin for Android Studio and it needs to run gradlew? That doesn't sound like a good idea: Android Studio itself does a bunch of stuff around invoking gradle and may have it built in; you should tell studio to invoke it, instead of doing it yourself. I don't know how that's done, though.
--
If you really want to invoke commands, use ProcessBuilder. But as I said, this is not what you want to do here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论