I want to build an Android Studio app (the Gradle build system), but I want to do this via the command line.
相关问题
- Could not read entry … from cache taskArtifacts.bi
- Could not read entry … from cache taskArtifacts.bi
- Non-static method isGooglePlayServicesAvailable an
- Configure gradle plugin based on future tasks
- How to fix the error Cannot change strategy of con
相关文章
- Android BuildConfig Field generating String incorr
- Android virtual device manager crashes with “doubl
- Compile and build with single command line Java (L
- What are the `^let` annotations in Android Studio
- Android Studio doesn't display logs by package
- Gradle Could not find method “() for arguments on
- Gradle Custom Plugin: gradleApi() vs Explicit Depe
- Advanced profiling is unavailable for the selected
Android Studio automatically creates a Gradle wrapper in the root of your project, which is how it invokes Gradle. The wrapper is basically a script that calls through to the actual Gradle binary and allows you to keep Gradle up to date, which makes using version control easier. To run a Gradle command, you can simply use the
gradlew
script found in the root of your project (orgradlew.bat
on Windows) followed by the name of the task you want to run. For instance, to build a debug version of your Android application, you can run./gradlew assembleDebug
from the root of your repository. In a default project setup, the resulting apk can then be found inapp/build/outputs/apk/app-debug.apk
. On a *nix machine, you can also just runfind . -name '*.apk'
to find it, if it's not there.Try this (OS X only):
brew install homebrew/versions/gradle110
gradle build
You can use
gradle tasks
to see all tasks available for the current project. NoAndroid Studio
is needed here.there are two build types to build your application using the Gradle build settings: one for debugging your application — debug — and one for building your final package for release — release mode.
Building in Debug Mode
First Navigate to Android studio project Root folder using CMD
run this command gradlew.bat assembleDebug
Build signed apk in Release Mode
Edit the build.gradle file to build your project in release mode:
Done.Good Luck!
Only for MAC Users
Extending Vji's answer.
Step by step procedure:
Copy and paste this command and hit enter:
As Vji suggested:
DON'T FORGOT TO ADD .(DOT) BEFORE /gradlew
Adding value to all these answers,
many have asked the command for running App in AVD after build sucessful.
Cheatsheet for running Gradle from the command line for Android Studio projects on Linux:
Should get you started..