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
You're likely here because you want to install it too!
Build
(On Windows
gradlew.bat
)Then Install
(The
-r
makes it replace the existing copy, add an-s
if installing on an emulator)Bonus
I set up an alias in my
~/.bash_profile
, to make it a 2char command.(Short for Build and Install)
This is an attempt at a full guide
1. Install Gradle and the Android SDK
Either
./gradlew
, orgradlew.bat
if on Windowschmod +x ./gradlew
may be necessaryFrom this point onwards,
gradle
refers to running Gradle whichever way you've chosen. Substitute accordingly.2. Setup the Android SDK
If you've manually installed the SDK
export ANDROID_HOME=<install location>
~/.profile
if it's not done automaticallyAccept the licenses:
yes | sdkmanager
sdkmanager
can be found in$ANDROID_HOME/tools/bin
sdkmanager
may have to be run as rootTry running
gradle
chown -R user:group $ANDROID_HOME
chmod 777 -R $ANDROID_HOME
3. Building
gradle tasks
lists all tasks that can be run:app:[appname]
is the prefix of all tasks, which you'll see in the Gradle logs when you're buildingSome essential tasks
gradle assemble
: build all variants of your appapp/[appname]/build/outputs/apk/[debug/release]
gradle assembleDebug
orassembleRelease
: build just the debug or release versionsgradle installDebug
orinstallRelease
build and install to an attached deviceadb devices
, check that your device is listed and device is beside itAutomatically build and install upon changes
This avoids having to continuously run the same commands
-t
: aka--continuous
, automatically re-runs the task after a file is changed--continue
: Continue after errors. Prevents stopping when errors occurRun
gradle -h
for more helpFor Mac use this command