谢谢mschonaker我找到了Maven的完整解决方案
首先,您需要在POM中添加插件
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<configuration>
<executable>${basedir}/scripts/run_app.sh</executable>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
在${basedir}/scripts/
dir中添加下一个内容的脚本:
adb shell am start -a android.intent.action.MAIN -n your.app.package/.YourMainActivity
Run Code Online (Sandbox Code Playgroud)
用于构建和运行app的命令
mvn clean install android:deploy; mvn exec:exec
Run Code Online (Sandbox Code Playgroud)