问题描述
我想要创建与Android Studio通过命令行在后台运行的进程相同的过程
I want create same process that android studio run in background through command line
like first clean project -> build project -> Run Project all through command line
(可能重复,但在一个答案中找不到所有过程)
我直到现在尝试的是
(may be duplicate but not found all process in one answer)what i try till now is
path upto project to run command
D:\ProjectWorkSpace\testDevelopmentV3_12_26
gradlew clean - To clean project
gradlew.bat assembleRelease - To Build project
D:\MySDKBackUp\sdk\platform-tools
adb push D:\ProjectWorkSpace\testDevelopmentV3_12_26\----\build\outputs\apk\----debug.apk /data/local/tmp/com.---.---
adb shell pm install -r "/data/local/tmp/com.----.---"
adb shell am start -n "com.---.---/com.---.---.SplashActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
above code to upload apk on device -> install apk -> run apk
但是问题是上述命令无法获取更新的数据(所做的新更改未反映在apk中)所以我想要当我们在android studio中按shift + F10(运行)时命中的所有命令,以便我可以从命令提示符下运行它。
But problem is above command not taking updated data (new changes made is not reflected in apk ) so i want all command that hit when we press shift+F10 (Run) in android studio so that i can run it from command prompt
在
path upto project to run command
D:\ProjectWorkSpace\testDevelopmentV3_12_26
gradlew installDebug
path upto your sdk/platform tools
D:\MySDKBackUp\sdk\platform-tools
adb push D:\ProjectWorkSpace\testDevelopmentV3_12_26\----\build\outputs\apk\----debug.apk /data/local/tmp/com.---.---
adb shell pm install -r "/data/local/tmp/com.----.---"
adb shell am start -n "com.---.---/com.---.---.SplashActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
推荐答案
您可以使用Gradle包装器命令行工具执行所有可用于Android项目的构建任务。它可以作为Windows的批处理文件(gradlew.bat)以及Linux和Mac的shell脚本(gradlew.sh)来使用,并且可以从使用Android Studio创建的每个项目的根目录中访问。
You can execute all the build tasks available to your Android project using the Gradle wrapper command line tool. It's available as a batch file for Windows (gradlew.bat) and a shell script for Linux and Mac (gradlew.sh), and it's accessible from the root of each project you create with Android Studio.
您希望与 Shift + F10
相同,因此请使用 gradlew installDebug
代替 gradlew assembleDebug
。它将在已连接的adb设备中生成并安装apk。
You want same as Shift+F10
so use gradlew installDebug
instead gradlew assembleDebug
. It will build and install apk in connected adb device.
感谢并参考以获取更多帮助。
Thank and refer Build Your App from the Command Line for more help.
感谢以上链接!
这篇关于如何从命令行重建和运行android项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!