Graddle build process
1. Configuration
Gradle builds can be executed in two ways, by installing gradle or by using gradleWrapper (tool which automatically downloads gradle in correct version)
Recommended approach:
Find JDK Installation Directory.
Open the default installation path for the JDK:
C:\Program Files\Java
There should be a subdirectory like:
C:\Program Files\Java\jdk1.6.0_10
Set the JAVA_HOME Variable
Once you have the JDK installation path:
- 1. Right-click the My Computer icon on your desktop and select Properties.
- 2. Click the Advanced tab, then click the Environment Variables button.
- 3. Under System Variables, click New.
- 4. Enter the variable name as JAVA_HOME.
- 5. Enter the variable value as the installation path for the Java Development Kit.
- 6. Click OK.
- 7. Click edit on PATH variable
- 8. Click NEW
- 9. Enter : C:\Program Files\Java\jdk1.6.0_10
- 10. Click OK
- 11. Click Apply Changes.
- 12. You need to have Android SDK installed, simplest way is to download Android Studio 2.3 and install it (Android Studio to c:\Android\Studio, SDK to c:\Android\SDK).
https://developer.android.com/studio/index.html#win-bundle[1]
- 13. After Android Studio install, please set ANDROID_HOME env. variable to dir you have SDK installed (eq. ANDROID_HOME=c:\Android\SDK the same procedure as JAVA_HOME Variable )
You need to run Android studio and agree to software license before using 'gradle'
Not Recommended approach
Install gradle according to this article:
https://docs.gradle.org/current/userguide/userguide_single.html#sec:prerequisites
NOTE: If you choose not recommended approach, then instead of gradlew command use gradle command for every example in this guide.
2. Building and releasing from command prompt
- 1. Download project from SVN
- 2. Open command prompt and go to project directory
- 3. Execute one of the following commands to build project:
Commands
All commands starts with gradlew keyword.
Commands to build the project :
- 1. assemble<Variant Name>
- 2. assemble<Build Type Name>
- 3. assemble<Product Flavor Name>
- - allows directly building a single variant. For instance assembleFlavor1Debug.
- - allows building all APKs for a given Build Type. For instance assembleDebug will build both Flavor1Debug and Flavor2Debug variants.
- - allows building all APKs for a given flavor. For instance assembleFlavor1 will build both Flavor1Debug and Flavor1Release variants.
The task assemble will build all possible variants:
| Flavors | Build Types |
| RAM | Release |
| PCH | Debug |
| FSH | |
| standard |
Apks are generated in ./build/outputs/apk folder.
Command to clean all generated files:
1. clean
For all commands use gradlew --help
Parameters
There are two parameters that can be passed to building script:
• projVersion – version of the project i.e 7.2.19
• hotfixnumber – hotfix number have to be lower than 10
To pass parameter use –P operator i.e -Photfixnumber=4
Examples:
gradlew assembleRelease -PprojVersion=7.2.19 : generate signed apks in versionName 7.2.19 and versionCode:702190 for all clients
gradlew assembleRelease -PprojVersion=7.2.19 -Photfixnumber=4 : generate signed apks in versionName 7.2.19 and versionCode:702194 for all clients
gradlew assemblePCHRelease : generate signed apk for PCH in default version
gradlew assemblePCHDebug : generate debugable apk for PCH in default version
gradlew assemblePCH : generate debugable and signed apk for PCH in default version
gradlew assemblePCH : generate debugable apks for all clients in default version
Tips
Commands can be shorten as long as they remain unique.
gradlew assemblePCHRelease can be shorten to gradlew aPCHR