Yo Daniel
Yo Daniel

Reputation: 124

how do i run cmd command on android programmatically with java code

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?

Upvotes: 0

Views: 891

Answers (1)

rzwitserloot
rzwitserloot

Reputation: 102902

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.

Upvotes: 1

Related Questions